From: Reff on
Basic stamp is a microcontroller. A connection to a personal computer allows the programmer to download software to the BASIC Stamp, which is stored in the onboard memory device. The step before i use basic stamp is image processing by using Matlab.

The basic stamp is not a problem,but i have a problem with Matlab. I must complete this image processing 1st. The picture consist only one chili with white background. Its just like chili recognition by their shape. How can i develop the program and all the step in Matlab for chili recognition? I have did until image thresholding. Is that Threshold is the final step?
Thanks a lot.
From: Gary on
What's with all the recent posts about identifying fruit and vegetables? Is that a common first project for a 2nd Semester Matlab course?
From: ImageAnalyst on
I gave you some code that is very straightforward for you to modify.
In just a few minutes you should have something that works. Let's see
what you have so far - post my code with your modifications so I can
see what's going wrong. If there are some images that it doesn't work
with then post those also.
From: Reff on
Chili image : http://img25.imageshack.us/img25/8735/chiliw.jpg

Code :
a = imread('chili.jpg');
b= imresize(a, [480 640]);
originalImage= rgb2gray(b);
subplot(3, 3, 1); imagesc(originalImage); colormap(gray(256));
caption = sprintf('Original Image');
title(caption);
axis square;
set(gcf, 'Position', get(0, 'ScreenSize'));

[pixelCount grayLevels] = imhist(originalImage);
subplot(3, 3, 2);
bar(pixelCount); title('Histogram of original image');
xlim([0 grayLevels(end)]);

thresholdValue = 128;
binaryImage = originalImage > thresholdValue;

binaryImage = imfill(binaryImage, 'holes');

hold on;
maxYValue = ylim;
hStemLines = stem(thresholdValue, maxYValue(2), 'r');
children = get(hStemLines, 'children');
set(children(2),'visible', 'off');
annotationText = sprintf('Thresholded at %d gray levels', thresholdValue);
text(double(thresholdValue + 5), double(0.5 * maxYValue(2)), annotationText, 'FontSize', 10, 'Color', [0 .5 0]);
text(double(thresholdValue - 70), double(0.94 * maxYValue(2)), 'Background', 'FontSize', 10, 'Color', [0 0 .5]);
text(double(thresholdValue + 50), double(0.94 * maxYValue(2)), 'Foreground', 'FontSize', 10, 'Color', [0 0 .5]);

subplot(3, 3, 3); imagesc(binaryImage); colormap(gray(256)); title('Binary Image, obtained by thresholding'); axis square;


Is that enough for image processing or need add another code?
Thanks
From: ImageAnalyst on
Yes that does image processing, but what do you want to do? Do YOU
think you're done or not done? I modified the code somewhat and it's
below:

clc;
clear all;
close all;
workspace;

rgbImage = imread('C:\Documents and Settings\Reff\My Documents
\Temporary stuff\chiliw.jpg');
subplot(3, 3, 1);
imshow(rgbImage);
caption = sprintf('Original RGB Image');
title(caption);

blueBandImage = rgbImage(:,:,3);
subplot(3, 3, 2);
imshow(blueBandImage);
caption = sprintf('Blue Channel');
title(caption);
set(gcf, 'Position', get(0, 'ScreenSize'));

[pixelCount grayLevels] = imhist(blueBandImage);
subplot(3, 3, 3);
bar(pixelCount);
title('Histogram of blue channel');
xlim([0 grayLevels(end)]);

thresholdValue = 128;

maxYValue = ylim;
hold on;
hStemLines = stem(thresholdValue, maxYValue(2), 'r');
children = get(hStemLines, 'children');
set(children(2),'visible', 'off');
annotationText = sprintf('Thresholded at %d gray levels',
thresholdValue);
text(double(thresholdValue + 5), double(0.5 * maxYValue(2)),
annotationText, 'FontSize', 10, 'Color', [0 .5 0]);
text(double(thresholdValue - 70), double(0.94 * maxYValue(2)),
'Background', 'FontSize', 10, 'Color', [0 0 .5]);
text(double(thresholdValue + 50), double(0.94 * maxYValue(2)),
'Foreground', 'FontSize', 10, 'Color', [0 0 .5]);

binaryImage = blueBandImage < thresholdValue;
binaryImage = imfill(binaryImage, 'holes');
subplot(3, 3, 4);
imshow(binaryImage, []);
caption = sprintf('Binarized, hole-filled image');
title(caption);

labeledImage = bwlabel(binaryImage, 8); % Label each blob so we
can make measurements of it
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle'); %
pseudo random color labels

subplot(3, 3, 5); imshow(labeledImage); title('Labeled Image, from
bwlabel()');
subplot(3, 3, 6); imshow(coloredLabels); title('Pseudo colored labels,
from label2rgb()');

% Get all the blob properties. Can only pass in originalImage in
version R2008a and later.
blobMeasurements = regionprops(labeledImage, blueBandImage, 'all');
numberOfBlobs = size(blobMeasurements, 1);
if numberOfBlobs > 1
message = sprintf('There are %d blobs. Now we will select only the
largest one.', numberOfBlobs);
uiwait(msgbox(message));
end
allBlobAreas = [blobMeasurements.Area];
% Get a list of the blobs that meet our criteria and we need to keep.
allowableAreaIndexes = allBlobAreas == max(allBlobAreas); % Take the
small objects.
keeperIndexes = find(allowableAreaIndexes);
% Extract only those blobs that meet our criteria, and
% eliminate those blobs that don't meet our criteria.
% Note how we use ismember() to do this.
keeperBlobsImage = ismember(labeledImage, keeperIndexes);
subplot(3, 3, 7);
imshow(keeperBlobsImage, []);
title('Only the largest blob.');