Skip to content

Commit 2d9f77a

Browse files
feat(edge-detection): add edge detection filter (d flag)
- Implement detect_edges() function in helpers.c to apply edge detection using pixel intensity gradients (Sobel operator). - Update helpers.h with function prototype for detect_edges(). - Add small 'd' flag handling in filter.c to apply the filter via CLI. - Running .\filter.exe d input.bmp output.bmp now generates an output.bmp with highlighted edges. - Verified functionality on sample BMP image; edges appear as black-and-white outlines. - Enhances image filtering suite with a new algorithm for outline detection.
1 parent 2f1ef2b commit 2d9f77a

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

filter.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ int main(int argc, char *argv[])
1515
char filterArr[argc - 3];
1616
int filterCount = 0;
1717

18-
while ((opt = getopt(argc, argv, filters)) != -1)
19-
{
20-
if (opt == '?')
21-
{
22-
printf("Invalid filter option\n");
23-
return 2;
24-
}
25-
filterArr[filterCount++] = (char)opt;
18+
for(int i=0; i<argc; i++){
19+
char temp = getopt(argc,argv,filters);
20+
if(temp == -1) break;
21+
filterArr[i]= temp;
22+
if(filterArr[i] == '?') {
23+
printf("Invalid filter option");
24+
return 1;
25+
}
2626
}
2727

2828

filter.exe

53.6 KB
Binary file not shown.

output.bmp

68.7 MB
Binary file not shown.

0 commit comments

Comments
 (0)