This was one of the first projects that I did, this is through the CS50 course. I only did the implementation of the filters which include, edge detection, grayscale, reflect, blur. There is a part of the program I will not be showing the reason being because it was given to me, that part of the code read in the image as an objects so I could then read through the rows of pixels. To see my implimentation of memory allocation and object creation in the C language take a look at Generation Generator project.
The filters are blur, edge detection, grayscale, reflect.
First the Results of My Image blur program writen in C.
Now the breakdown.
First is the loop through of each pixel of the image, I did this with for loops running through the height
and width of the image. A factor variable is defined to set the level of blur.
Then the rest is passed into a single function... I really would like to rework this but I think the ametuer
state of this program excentuates growth.
get_avg() Function
The start of the get_edge() function defines some of the variables
This part of the function is used to gather a chunk of the image of size simage[][]. The
factor_size variable is used to define the amount of pixels to gather above, below, left,
and right. The matrix_size variable defines the total number of pixels in this image chunk.
The for loop is then used to get each of the pixels in the selected area. This essential defines a new pixel
size.
The following part of this function adds up all of the rgb values.
After all of the rgb values have been added up. They are divided by the total number of pixels matrix_size in the pixel, to get the average.
Once the average of each color is gathered it is then applied to the image.
Then rinse and repeat for each pixel in the image.
Summary
This is a fairly simple implementation of blurring an image and works well. I do like that is has a factor
variable that could be user defined to set a custom level of blur. It adds flexability to my otherwise rigid code.
Click Here for the full code.