Effective pixel editing in an image
source link: https://www.codesd.com/item/effective-pixel-editing-in-an-image.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Effective pixel editing in an image
I have an 8bit Image (stored in an Array) containing black(0) and white(255) pixels. Say I want to change all Black pixels in the image to grey(say 120) pixels. What is the fastest way I can change Black to Grey.
I thought of two approaches-
Start checking every single pixel in the image. As soon as a black pixel is found change it to grey. Continue till end of image. (Slower but easier)
Start checking pixels. When a black pixel is found maintain a counter to track it. Continue incrementing the counter till the next white pixel. Then goto the counter and use a fast function like memset to change a group of black pixels to grey. (Not sure but I think this may be faster)
I have a huge 1GB image therefore approach 1 is pretty slow. Is there a better(faster) way to change/edit pixels?
Probably quicker to do it a word at a time (using word aligned accesses).
You can just bitwise OR with 0x78787878 (assuming 32 bits). This will not affect white pixels but will set black pixels to the required value.
Related Articles
How to add a fade effect when editing the background image using .css in Jquery
Effective way to make negative image without external dll
Handling pixels in a buffered image through a table
Retrieve the pixel values of an image with Haskell
Edit to upload images to a database
The most optimal way to detect whether black (or any color pixel) exists in an image file?
Circle the circle (using the pixels applied in an image with the for loop)
Can I edit the thumbnail image in JFIF files?
c ++ How to take pixel coordinates from an image?
View the pixel intensities of an image
Changing the background color of the page with a blur effect according to the cursor image
iOS Performance Tuning: The Fastest Way to Get Pixel Color for Large Images
How to improve the performance of changing the pixel color of the image using WriteableBitmapEx in Windows 10?
Memory leak when creating the pixel buffer of the image
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK