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:
changing the color of regions of an image

Subject: changing the color of regions of an image

From: bob

Date: 2 Mar, 2012 21:17:36

Message: 1 of 2

Hey,

I have a micrograph with different features with different sizes. I used the following code, to detect and remove regions with certain properties like area.
Now, I want to change the color of regions with specific values of area. But I couldn't find a way to do that.
I need to change the bw image to RGB but for example with regions having area less than 1000 to be displayed in red.

Any comments?
thanks.

a= imread('test.jpg');
b= im2bw(a);

c= bwconncomp(b);
stats= regionprops(c, 'Area');
idx= find([stats.Area]>1000);
d= ismember(labelmatrix(c), idx);

Subject: changing the color of regions of an image

From: ImageAnalyst

Date: 2 Mar, 2012 22:53:25

Message: 2 of 2

On Mar 2, 4:17 pm, "bob " <behzad.maj...@gmail.com> wrote:
> Hey,
>
> I have a micrograph with different features with different sizes. I used the following code, to detect and remove regions with certain properties like area.
> Now, I want to change the color of regions with specific values of area. But I couldn't find  a way to do that.
> I need to change the bw image to RGB but for example with regions having area less than 1000 to be displayed in red.
>
> Any comments?
> thanks.
>
> a= imread('test.jpg');
> b= im2bw(a);
>
> c= bwconncomp(b);
> stats= regionprops(c, 'Area');
> idx= find([stats.Area]>1000);
> d= ismember(labelmatrix(c), idx);

-------------------------------------------------------------------------------------
What makes you think im2bw() will give you a good segmentation of your
objects? Well anyway, after that you could simply do
b = bwareaopen(b, 1000);
Then when you call regionprops() you will be guaranteed of not having
any regions of 1000 pixels or fewer.

By the way, why don't you see my BlobsDemo tutorial at:
http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
There are also color demos in there.
You can upload your photos to tinypic.com if you want further advice.

Tags for this Thread

No tags are associated with 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