简体   繁体   中英

black and white Image processing in C#

替代文字
(source: googlepages.com )

In above image I want to mark Circle's edge with red color something like this

替代文字
(source: googlepages.com )

I have no idea how should proceed, Any help/suggestions would be highly appreciated...

Quick and dirty solution. Run the image pixel by pixel, if the color change, just paint the pixel red.

PS: Notice this may not work for a square, unless you do the same vertically and horizontally

Morphological filtering would work great as long as you are working with binary images like the one you provided. Dilate the image and then subtract the original.

alt text http://img29.imageshack.us/img29/1420/morphf.png

Here's a MATLAB example:

lImage = zeros(19, 19, 3);
lImage(7:13, 7:13, :) = repmat( ...
    [0 0 1 1 1 0 0; ...
     0 1 1 1 1 1 0; ...
     1 1 1 1 1 1 1; ...
     1 1 1 1 1 1 1; ...
     1 1 1 1 1 1 1; ...
     0 1 1 1 1 1 0; ...
     0 0 1 1 1 0 0;], [1 1 3]);
figure; imshow(lImage);
lOutline = imdilate(lImage, strel('disk', 1)) - lImage;
lOutline(:, :, 2:3) = 0;
figure; imshow(lImage + lOutline);

You almost assuredly want to use the Canny Edge Detector , which should be able to do this easily. My company 's product line includes just such a tool, and this is the output of running it: alt text http://www.plinth.org/_images/image1Output.gif

I guess you need an edge detection algorithm. Try this or this .

What you are looking for is edge detection. You can find a number of resources for the general algorithm on Google:

http://www.google.com/search?q=edge+detection+.net

i can at least point you in the direction of some pretty neat edge detection filters: http://www.codeproject.com/KB/GDI-plus/edge_detection.aspx

i imagine it should suit you quite well

Never had to do anything like this, but a powerful tool for complex image manipulation is:

http://www.imagemagick.org/script/index.php

Lots of documentation and examples -- and a .NET wrapper if you'd rather not call the executable.

Interesting problem - I'm assuming the 'white circle' in your example is actually another image - meaning you aren't drawing the circle yourself?

If so, you might scan through all of the pixels to find a white pixel that has black on at least one side of it (either 4 directions or 8 including corners). If it is a match then swap it to red. If not then ignore it.

I doubt that is the best way to do it, but if it is only black and white, this might get you started.

There is several approach for this.

The first one is: - you know that there is a circle, and you juste need to find where is the center and how is the radius. So you can use Hough transformation to find these, and them draw your circle in red. Read this topic or this one

The 2nd is to use edge detection. Here or here ( here for more theoritical point of view)

Ultimately you want to edit the pixels of the image. That question has already been answered here by Marc Gravell .

Then, based on which option you choose, either LockBits or GetPixel/SetPixel, you will need to loop through and look at the per pixel color values. Keep looping until you hit a white pixel.

Once you do, check in all directions around it, if you find a black pixel, then color that white pixel red. This is of course the most simplistic answer, and there are ways to optimize it, but it will work.

For instance, if you wanted to limit the color changing to just the four directly adjacent pixels, you could, rather than also checking the diagonals.

Edge detection? Image processing? OpenCV ! There are C# wrappers for the lib. Not the "easy" solution but any exp you get with this lib is a good resume builder. If you company is doing image processing they are probably already using it.

I think the answer to your question is the answer

http://csharpkodu.blogspot.com.tr/2014/04/grafik-snfna-devam.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM