5

Effective pixel editing in an image

 3 years ago
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.
neoserver,ios ssh client

Effective pixel editing in an image

advertisements

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-

  1. 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)

  2. 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

Hey guys, Im trying to add a fadein effect while changing my background image using .css in Jquery I dont really know much about java, hoping someone can help me out here! The code for changing css background image is pretty simple here: $(document).

Effective way to make negative image without external dll

That is the solution to make a negative from a image in C# Windows Forms without any dlls and in a effective, fast way?The best way to do this is directly accessing the pixels with bitmap data. Just to add some timing details: Performing Negate on an

Handling pixels in a buffered image through a table

I'm currently following a series on Java game development from scratch. I understand most java and oop concepts but have very little experience when dealing with graphics and hardware acceleration. The lines of code that I am questioning are: private

Retrieve the pixel values ​​of an image with Haskell

Is there a way or a library available that can load an image (jpeg, png, etc) and assign the pixel values of that image into a list or matrix? I'd like to do some experiments with image and pattern recognition. A little nudge in the right direction w

Edit to upload images to a database

Just finished creating a file upload function; for images to be uploaded to a database. This is working fine. The code below is a shortened version of the controller with just one image in it. [HttpPost] public ActionResult Create(CarAdvert caradvert

The most optimal way to detect whether black (or any color pixel) exists in an image file?

What's the best and most flexible algorithm to detect any black (or colored pixel) in a given image file? Say I'm given an image file that could, say, have a blue background. And any non blue pixel, including a white pixel, is counted as a "mark"

Circle the circle (using the pixels applied in an image with the for loop)

I want to draw a circle (with 1 or 2 for loops) using pixels position (starts from top left and ends at bottom right) I successfully drew a rectangle with this method: private void drawrect(int width,int height,int x,int y) { int top=y; int left=x; i

Can I edit the thumbnail image in JFIF files?

Can I edit the thumbnail image inside JPG/JFIF files? If this is possible--how so (using what utility)? The end result needs to be that the thumbnail image "can" be a wholly different image than the jpeg. Thank you much, MichaelTypically, thumbn

c ++ How to take pixel coordinates from an image?

I have an image in C++ and I want to take the coordinates of a pixel (relatives to the image) clicking on it (with my picture available and open to click on it). I don't know how to define the signal and the slot required to do this. Thanks. eventFil

View the pixel intensities of an image

How to view the pixel intensities of an image in matlab by moving the mouse pointer over the image? I used: imshow(imread('image.jpg')); But there is no option to view the pixel intensities of each pixel in the image. For example, In MS-paint, while

Changing the background color of the page with a blur effect according to the cursor image

Is it possible to get a similar effect with JavaScript or CSS ? What would be the best method to accomplish this effect. Basically what it does is it changes the background color of the page with some nice blur effect depending on the slider image. S

iOS Performance Tuning: The Fastest Way to Get Pixel Color for Large Images

There are a number of questions/answers regarding how to get the pixel color of an image for a given point. However, all of these answers are really slow (100-500ms) for large images (even as small as 1000 x 1300, for example). Most of the code sampl

How to improve the performance of changing the pixel color of the image using WriteableBitmapEx in Windows 10?

I am currently working on the part where I want to download a set of images and change their pixel colour for example to red, yellow, etc. I did some research and came across a third party API called WriteableBitmapEx. I used the following code and i

Memory leak when creating the pixel buffer of the image

I am trying to create a video with an input of images using AVAssetWriterInput for which I need to create a pixel buffer of my images. For that I call the function below which works, but after creating a few videos the app receives a memory warning a

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK