object shape detection from the image.
2 次查看(过去 30 天)
显示 更早的评论
Hello, I want to detect the shape from the attached image.Please help me to detect the shape from the image.Here is the image link(imgur.com/cpNL9oH)and i want to detect the irregular shape from this image and from this another image(imgur.com/JvRCD0g)i want to detect the circle shape.Like this(<http://imgur.com/tUtUvNM).This> is a mammogram photo. I did some segmentation operation.
0 个评论
采纳的回答
Image Analyst
2013-11-25
I'm not even sure where the mass starts and stops. I suggest you consult the literature http://iris.usc.edu/Vision-Notes/bibliography/contentsmedical.html#Medical%20Applications,%20CAT,%20MRI,%20Ultrasound,%20Heart%20Models,%20Brain%20Models for algorithms.
0 个评论
更多回答(1 个)
Naishil shah
2013-12-2
1 个评论
Image Analyst
2013-12-3
Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
% Read in a standard MATLAB color demo image.
folder = 'C:\Users\shah\Documents';
baseFileName = 'cc1.jpg';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName)
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows, columns, numberOfColorBands] = size(rgbImage);
% Display the original color image.
subplot(2, 2, 1);
imshow(rgbImage);
title('Original Color Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Get binary image of the green rectangle
binaryImage = redChannel < 200 & greenChannel > 200 & blueChannel < 200;
% Display the image.
subplot(2, 2, 2);
imshow(binaryImage);
title('Binary Image', 'FontSize', fontSize);
% Fill the rectangle
binaryImage = imfill(binaryImage, 'holes');
% Get rid of small things
% binaryImage = bwareaopen(binaryImage, 1000);
% Get the convex hull
binaryImage = bwconvhull(binaryImage, 'objects');
% Display the image.
subplot(2, 2, 3);
imshow(binaryImage);
title('Binary Image', 'FontSize', fontSize);
% Measure areas
measurements = regionprops(binaryImage, 'Area', 'BoundingBox');
% Take the largest one
allAreas = [measurements.Area];
[sortedAreas, indexes] = sort(allAreas, 'Descend');
% Get it's bounding box.
boundingBox = measurements(indexes(1)).BoundingBox;
% Crop the image
croppedImage = imcrop(rgbImage, boundingBox);
% Display the cropped color image.
subplot(2, 2, 4);
imshow(croppedImage);
title('Cropped Color Image', 'FontSize', fontSize);
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!