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:
image processing

Subject: image processing

From: Mathew Thomas

Date: 10 Aug, 2009 23:29:03

Message: 1 of 6

Hello everyone,

I have a color image and want to find the edges. The image has two colors - black n brown... I only want to find the edges of the brown portion. How can I do this ?? I tried thresholding, but I guess I could not apply it right...Any help is welcome..

Thank you,

Matt

Subject: image processing

From: ImageAnalyst

Date: 11 Aug, 2009 01:15:55

Message: 2 of 6

On Aug 10, 7:29 pm, "Mathew Thomas" <mathe...@gmail.com> wrote:
> Hello everyone,
>
> I have a color image and want to find the edges. The image has two colors - black n brown... I only want to find the edges of the brown portion. How can I do this ?? I tried thresholding, but I guess I could not apply it right...Any help is welcome..
>
> Thank you,
>
> Matt

----------------------------------------------------------------------------------------------------------------
Matt:
Try this demo:
Good luck,
ImageAnalyst


% Demo macro to outline brown regions.
% by ImageAnalyst
clc;
close all;
workspace;
rgbImage = uint8(zeros([200 200 3]));
rgbImage(60:120, 60:120, 1) = 150;
rgbImage(60:120, 60:120, 2) = 80;
subplot(3,1,1);
imshow(rgbImage);
title('Original image.');
% Find brown. Since the only other color is black [0, 0, 0],
% brown will be anyplace that is non-zero.
% But for generality, let's look for red between 120 and 180
% and for green between 50 and 100.
inRedRange = rgbImage(:,:, 1) > 120 & rgbImage(:,:, 1) < 180;
inGreenRange = rgbImage(:,:, 2) > 50 & rgbImage(:,:, 2) < 100;
% AND them together to find where they're both true.
binaryImage = inRedRange & inGreenRange;
subplot(3,1, 2);
imshow(binaryImage, []);
title('Thresholded image.');
% Now find the boundaries
[boundaries, labeledImage] = bwboundaries(binaryImage,'noholes');
% Display them over the original image.
subplot(3,1, 3);
imshow(rgbImage);
hold on; % Don't let plot() blow away our image.
title('Original image with boundaries.');
for k = 1:length(boundaries)
    thisBoundary = boundaries{k};
    plot(thisBoundary(:,2), thisBoundary(:,1), 'w', 'LineWidth', 2)
end
% Maximize window.
set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.

Subject: image processing

From: Mathew Thomas

Date: 13 Aug, 2009 17:34:03

Message: 3 of 6

Thank you so much. You really helped me understand.

Matt

Subject: image processing

From: Chaos

Date: 13 Aug, 2009 22:23:04

Message: 4 of 6

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <56457914-5735-46aa-8352-5a8dc00f781e@k26g2000vbp.googlegroups.com>...
> On Aug 10, 7:29?pm, "Mathew Thomas" <mathe...@gmail.com> wrote:
> > Hello everyone,
> >
> > I have a color image and want to find the edges. The image has two colors - black n brown... I only want to find the edges of the brown portion. How can I do this ?? I tried thresholding, but I guess I could not apply it right...Any help is welcome..
> >
> > Thank you,
> >
> > Matt
>
> ----------------------------------------------------------------------------------------------------------------
> Matt:
> Try this demo:
> Good luck,
> ImageAnalyst
>
>
> % Demo macro to outline brown regions.
> % by ImageAnalyst
> clc;
> close all;
> workspace;
> rgbImage = uint8(zeros([200 200 3]));
> rgbImage(60:120, 60:120, 1) = 150;
> rgbImage(60:120, 60:120, 2) = 80;
> subplot(3,1,1);
> imshow(rgbImage);
> title('Original image.');
> % Find brown. Since the only other color is black [0, 0, 0],
> % brown will be anyplace that is non-zero.
> % But for generality, let's look for red between 120 and 180
> % and for green between 50 and 100.
> inRedRange = rgbImage(:,:, 1) > 120 & rgbImage(:,:, 1) < 180;
> inGreenRange = rgbImage(:,:, 2) > 50 & rgbImage(:,:, 2) < 100;
> % AND them together to find where they're both true.
> binaryImage = inRedRange & inGreenRange;
> subplot(3,1, 2);
> imshow(binaryImage, []);
> title('Thresholded image.');
> % Now find the boundaries
> [boundaries, labeledImage] = bwboundaries(binaryImage,'noholes');
> % Display them over the original image.
> subplot(3,1, 3);
> imshow(rgbImage);
> hold on; % Don't let plot() blow away our image.
> title('Original image with boundaries.');
> for k = 1:length(boundaries)
> thisBoundary = boundaries{k};
> plot(thisBoundary(:,2), thisBoundary(:,1), 'w', 'LineWidth', 2)
> end
> % Maximize window.
> set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.

IA is at again with another load of bloated crap code! this looks like something out of a textbook or matlab example tutorial, lame!

go here
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/

scroll down find what you need

Subject: image processing

From: ImageAnalyst

Date: 14 Aug, 2009 01:37:40

Message: 5 of 6

Chaos:
The only crap I would ever post is if I included your prior response.
We've been over this before. If I thought anyone cared about your
opinion then I'd be offended and might feel it necessary to defend
myself again. Luckily you've made that totally unnecessary.

You swoop in here every few months with a few of your insults and
unhelpful comments, while I'm here helping every day. Matthew did not
ask for your opinion of my code - in fact he thanked me for my code.
Quit while you're ahead (if you can call it that). With every insult
and snide remark you hurl (and I'm not your only target) you just
damage your reputation even further.
ImageAnalyst

Subject: image processing

From: Mathew Thomas

Date: 14 Aug, 2009 14:41:04

Message: 6 of 6

Chill guys!!!

ImageAnalyst, the program you send really helped me out...I spend hours trying to figure it out and you replied in like 10 minutes. And Chaos, thanks for your help too, but you can do it in a nice way...If you feel you are a great programmer, help others as you did, but without undermining others.....

Good luck guys!!!

Matt

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <39a4b1f6-5198-4a95-b68c-deb80e856484@o6g2000yqj.googlegroups.com>...
> Chaos:
> The only crap I would ever post is if I included your prior response.
> We've been over this before. If I thought anyone cared about your
> opinion then I'd be offended and might feel it necessary to defend
> myself again. Luckily you've made that totally unnecessary.
>
> You swoop in here every few months with a few of your insults and
> unhelpful comments, while I'm here helping every day. Matthew did not
> ask for your opinion of my code - in fact he thanked me for my code.
> Quit while you're ahead (if you can call it that). With every insult
> and snide remark you hurl (and I'm not your only target) you just
> damage your reputation even further.
> 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