Jump to content

Image Filter with C language


Black_Kaiser
 Share

Recommended Posts

Image manipulation with C. Beginners guide.

As an image is a collection of pixels grouped together in a certain order and each pixels is a byte which contains Red Green and Blue value, we can change the position or the values according to what we like to achieve. Here is a program which has four functions Grayscale, Reflect, Blur and Edge detection which converts an image into each of the respective functions.

Gray scale: Nothing much to explain here. The new value of each RGB value of each pixel is the average value of the current RGB value.  Eg:- Red = 126, Green = 211 and Blue = 107 and so the average value of these 3 RGB value is (Red + Green + Blue)/3 = 444/3 = 148. So Red = 148, Green = 148 and Blue = 148.

Reflect: Loop through width/2 and copy the pixels of the first half to the right.

Blur Image algorithm explanation:- https://medium.com/mobile-app-development-publication/blurring-image-algorithm-example-in-android-cec81911cd5e

Edge detection algorithm explanation:- https://medium.com/@nikatsanka/comparing-edge-detection-methods-638a2919476e

Note: I know i hard code blur function instead of nesting more loops. Its mainly to show beginners how the algorithm behind blur image works.

filter.zip

  • Like 24
  • Haha 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...