Prev: RBF neural network - How to estimate "spread"
Next: Plotting periodical measurement data with jitter to matlab
From: ImageAnalyst on 3 Dec 2009 17:35 On Dec 3, 5:30 pm, "wilson " <wilson_silver3...(a)hotmail.com> wrote: > ImageAnalyst From the code above what is the figure number for row1, row2, col1 and col 2. still error i dunno why! Perhaps i put wrong figure! > croppedImage = fullImage(row1:row2, column1:column2); ---------------------------- Um, that is the bounding box of your iris - we've talked about this already.
From: wilson on 3 Dec 2009 18:22 ImageAnalyst i can't get ur point. Can you show me how to crop the iris based on the code above? Sorry i am totally confuse now perhaps i am noob in Matlab!
From: ImageAnalyst on 3 Dec 2009 22:35 On Dec 3, 6:22 pm, "wilson " <wilson_silver3...(a)hotmail.com> wrote: > ImageAnalyst i can't get ur point. Can you show me how to crop the iris based on the code above? Sorry i am totally confuse now perhaps i am noob in Matlab! ---------------------------------------------------------------------------------- Allright. I simply just added that line to my previous code (look way down near the very end of the code): Again, fix the line breaks introduced by the newsreader: % function test % Demo to find eyes in a face image. % by ImageAnalyst % function test clc; close all; clear all; workspace; % Show the Workspace panel. % % Read in color image. rgbImage = imread('C:\Documents and Settings\tk2013\My Documents \Temporary stuff\face2.jpg'); [rows columns, numberOfColorPlanes] = size(rgbImage); subplot(3, 3,1); imshow(rgbImage); title('Color Image'); set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure. redPlane = rgbImage(:,:, 1); greenPlane = rgbImage(:,:, 2); bluePlane = rgbImage(:,:, 3); redThreshold = 90; greenThreshold = 80; blueThreshold = 100; binaryImage = (redPlane < redThreshold) & (greenPlane < greenThreshold) & (bluePlane < blueThreshold); binaryImage = ~binaryImage; subplot(3, 3,2); imshow(binaryImage, []); title('Color Segmented / Binary Image'); labeledImage = bwlabel(binaryImage); blobMeasurements = regionprops(labeledImage, 'all'); numberOfBlobs = length(blobMeasurements); maxArea = -1; indexForMaxArea = 1; for k = 1 : numberOfBlobs % Loop through all blobs. % Find the mean of each blob. (R2008a has a better way where you can pass the original image % directly into regionprops. The way below works for all versions including earlier versions.) thisBlobsPixels = blobMeasurements(k).PixelIdxList; % Get list of pixels in current blob. blobArea = blobMeasurements(k).Area; % Get area. if blobArea > maxArea maxArea = blobArea; indexForMaxArea = k; biggestBlobPixels = thisBlobsPixels; end end % Get an image with just the largest blob faceImage = zeros(rows, columns); faceImage(biggestBlobPixels) = 1; subplot(3, 3,3); imshow(faceImage, []); title('The Face'); % Do a fill to get the face without the eyes and mouth. filledImage = imfill(faceImage, 'holes'); % Find just the eyes and mouth eyesImage = ~faceImage .* filledImage; subplot(3, 3,4); imshow(eyesImage, []); title('Only the eyes and mouth'); % Do a closing to connect pixels in eye and mouth area. closedImage = imclose(eyesImage, ones(5)); subplot(3, 3,5); imshow(closedImage, []); title('eyes and mouth'); % Keep just the blobs bigger than 100. eyesOnlyImage = bwareaopen(closedImage, 500); subplot(3, 3,6); imshow(eyesOnlyImage, []); title('Eyes only'); % Label this image. labeledImage2 = bwlabel(eyesOnlyImage); % Find the bounding box of the eyes. blobMeasurements2 = regionprops(labeledImage2, 'BoundingBox'); numberOfBlobs = length(blobMeasurements2); % Plot the bounding box of the eyes over the original image. for k = 1 : numberOfBlobs % Loop through all blobs. blobBoundingBox = blobMeasurements2 (k).BoundingBox; % Get centroid. % Crop out this blob. row1 = blobBoundingBox(2); col1 = blobBoundingBox(1); row2 = row1 + blobBoundingBox(4) - 1; col2 = col1 + blobBoundingBox(3) - 1; % Get the box (x,y) coordinates. x = [col1 col2 col2 col1 col1]; y = [row1 row1 row2 row2 row1]; subplot(3, 3,1); hold on; % Don't let image get blown away by the plotting of the box. plot(x,y, 'r', 'LineWidth', 2); % Crop the eye and put it in a new image croppedImage = rgbImage(row1:row2, col1:col2, :); subplot(3, 3, k + 6); imshow(croppedImage); end msgbox('Done!');
From: wilson on 4 Dec 2009 08:35 ImageAnalyst > % Crop the eye and put it in a new image > croppedImage = rgbImage(row1:row2, col1:col2, :); row1:row2, col1:col2, then why need another :? can u explain for me?
From: ImageAnalyst on 4 Dec 2009 08:46
On Dec 4, 8:35 am, "wilson " <wilson_silver3...(a)hotmail.com> wrote: > ImageAnalyst> % Crop the eye and put it in a new image > > croppedImage = rgbImage(row1:row2, col1:col2, :); > > row1:row2, col1:col2, then why need another :? can u explain for me? ------------------------------------------------------ The final : means to take all 3 color bands. Recall that : in MATLAB basically means "all" when it's used alone as in this case. rgbImage is a 3 color image, thus croppedImage will also be a 3 color image because I used the :. |