Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!k26g2000vbp.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: image processing
Date: Mon, 10 Aug 2009 18:15:55 -0700 (PDT)
Organization: http://groups.google.com
Lines: 55
Message-ID: <56457914-5735-46aa-8352-5a8dc00f781e@k26g2000vbp.googlegroups.com>
References: <h5qafv$hej$1@fred.mathworks.com>
NNTP-Posting-Host: 75.186.70.56
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1249953355 2629 127.0.0.1 (11 Aug 2009 01:15:55 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 11 Aug 2009 01:15:55 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: k26g2000vbp.googlegroups.com; posting-host=75.186.70.56; 
	posting-account=0rLUzAkAAABojYSRC64DkTbtiSCX77HH
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; 
	GTB6; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 
	3.5.21022; AskTB5.5),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:562269


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.