Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Boundary in Black and White image

Subject: Boundary in Black and White image

From: andrea

Date: 7 Jul, 2010 13:10:21

Message: 1 of 5

Hi,

I have a BW image (black=0 white=255).
I want to find the border pixels between black pixels and white pixels.

I wrote this code:

for col = 1:size(img,2)
[r c v] = find(img(:,col)==255, 1, 'first');
...
end

But in the image I have horizontal and vertical edge and, in the case of vertical edge, the output of fuction find is the first pixel of the edge.

How can I do?

Thank you

Andrea

Subject: Boundary in Black and White image

From: Sean

Date: 7 Jul, 2010 14:45:19

Message: 2 of 5

"andrea " <nacchio1983@yahoo.it> wrote in message <i11ubt$ad7$1@fred.mathworks.com>...
> Hi,
>
> I have a BW image (black=0 white=255).
> I want to find the border pixels between black pixels and white pixels.
>
> I wrote this code:
>
> for col = 1:size(img,2)
> [r c v] = find(img(:,col)==255, 1, 'first');
> ...
> end
>
> But in the image I have horizontal and vertical edge and, in the case of vertical edge, the output of fuction find is the first pixel of the edge.

It's hard to understand what you're saying without seeing an image. Could you post an image somewhere so we can see it?

If I'm understanding you correctly what you want is every pixel that's neither black or white but touching a black or white object. Is that correct? Or do you just want all non -(black, white) pixels?

Subject: Boundary in Black and White image

From: Image Analyst

Date: 7 Jul, 2010 16:33:07

Message: 3 of 5

andrea:
Simply use bwboundaries(). See my image processing demo for an example:
http://www.mathworks.com/matlabcentral/fileexchange/25157
-ImageAnalyst

Subject: Boundary in Black and White image

From: mustafa bayraktar

Date: 23 Feb, 2011 19:48:09

Message: 4 of 5

"Image Analyst" wrote in message <i12a83$b8v$1@fred.mathworks.com>...
> andrea:
> Simply use bwboundaries(). See my image processing demo for an example:
> http://www.mathworks.com/matlabcentral/fileexchange/25157
> -ImageAnalyst

Hello sir, I am trying to do segmentation..But my main problem is
how to get the pixel coordinates of an segmented area.For example
on a black surface, I have a white loop.I just want to divide this loop into 50 points and
I just want to know the x,y coordinates of these points.

Thank you very much

Subject: Boundary in Black and White image

From: ImageAnalyst

Date: 23 Feb, 2011 22:06:31

Message: 5 of 5

mustafa bayraktar:
You can do
[rows columns] = find(binaryImage);
That will give you all the row,column pairs for all white pixels
(perhaps there are hundreds or thousands of them).

I'm not sure what you're doing with those since you don't need those
directly to do image segmentation. You can do image segmentation with
this basic process
1. process image so that it can be thresholded.
2. threshold it.
3. label it with bwlabel or bwconncomp
4. call regionprops to do the measurements
It's not necessary to ever actually know what all the (row,column)
coordinate pairs are. But whatever....

As far as somehow dividing that up into only 50 pixels, then you're on
your own, or else you need to tell us more what you're thinking.
ImageAnalyst

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us