I have attached two photos of component. In one of the piece there is a portion cut. Is it possible to produce output with or without comparison with the default using image processing. can someone provide the code?

2 Ansichten (letzte 30 Tage)

Akzeptierte Antwort

Image Analyst
Image Analyst am 11 Jan. 2015
Simply take the red channel, threshold it, find the area, and if the area is less than some minimum allowable area, alert the user. Try this
rgbImage = imread(filename);
redChannel = rgbImage(:,:,1);
binaryImage = redChannel < 128; % Whatever...
binaryImage = bwareaopen(binaryImage, 100);
labeledImage = bwlabel(binaryImage, 4);
measurements = regionprops(labeledImage, 'Area');
allAreas = [measurements.Area];
minAllowableArea = 500; % Whatever.
for k = 1 : length
fprintf('Area = %d pixels.', allAreas(k));
if allAreas(k) < minAllowableArea
message = sprintf('Blob #%d is too small at %d pixels', k, allAreas(k));
uiwait(warndlg(message));
end
end
That's untested so you might have to tweak it.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by