% What I would like the program to do is, to ask the user if they want to select another image to process. How do I do that?
clear all[file,path] = uigetfile('*.jpg')rgbImage = imread (strcat(path, file));[rows, columns, numberOfColorChannels] = size(rgbImage); % Get the dimensions of the image.
subplot(2, 2, 1);% Display the original color image on the first box
imshow(rgbImage);% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1); % arrayName(rowIndex, columnIndex, colorChannelIndex). Colon : means "all".
greenChannel = rgbImage(:, :, 2);blueChannel = rgbImage(:, :, 3);% Find white, where each color channel is more than , say, 200
thresholdValue = 200;binaryImage = redChannel > thresholdValue & greenChannel > thresholdValue & blueChannel > thresholdValue;% Display the binary image.
subplot(2, 2, 2); % display the binary image on the 2nd plot
imshow(binaryImage);% Determine the areas on this first pass.
numRegions = 0;[labeledImage, numRegions] = bwlabel(binaryImage); % returns the number of distinct regions that make up the shape
props = regionprops(labeledImage, 'Area'); % returns measurements for the set of properties specified by 'Area'
allAreas = sort([props.Area]); % returns a collection of index vectors
% Get rid of small blobs - blobs smaller than 500 pixels to see the tumor
% more clearly
binaryImage = bwareaopen(binaryImage, 500);% Display the binary image.subplot(2, 2, 3); % plots the image with lesser blobs on 3rd plot
imshow(binaryImage);% Now crop out the blob - the one in the lower left.
[labeledImage, numRegions] = bwlabel(binaryImage);% Extract blob
binaryImage = ismember(labeledImage, 1);[labeledImage, numRegions] = bwlabel(binaryImage);props = regionprops(labeledImage, 'BoundingBox');subImage = imcrop(rgbImage, props.BoundingBox);% Display the cropped image.
subplot(2, 2, 4); % plot the final cropped image in the original way showing the tumor
imshow(subImage);
MATLAB: Ask user for another image or abort
image processingMATLABtumor
Related Question
- How can i separate all the connected regions in a binary image and display them individually.
- Crop dark area and display the face only
- Getting rid of noise
- Measure object width in a depth image (able to choose shoulder width in the image)
- How to count number of white cirlces in a bw image
- Dividing a figure into regions
Best Answer