From: Alex on 27 May 2010 06:44 Recently I'm working on a project about hole identification and positioning with MATLAB , for this mean I use IPT toolbox, the process is simple I take a picture with camera send it to Pc and then start the process. After changing the picture from RGB to binary type I used some adjustments for background (contarst,etc.)then morphological tools used , e.g. delation and then an erosion, the structuring elements are same ( both are disk with equal radius). this process called closing. Now the problem is disk situation after closing , the lines around are not equal and it is not a complete circle , I have tested different boundary and perimeter functions as well as some filters and reconstruction, they did not help . if you have some ideas I would be glad to hear them, thank you in advance for your help.
From: Sean on 27 May 2010 10:52 "Alex " <ashkandav(a)yahoo.com> wrote in message <htlidk$ohv$1(a)fred.mathworks.com>... > Recently I'm working on a project about hole identification and positioning with MATLAB , for this mean I use IPT toolbox, the process is simple I take a picture with camera send it to Pc and then start the process. > > After changing the picture from RGB to binary type I used some adjustments for background (contarst,etc.)then morphological tools used , e.g. delation and then an erosion, the structuring elements are same ( both are disk with equal radius). this process called closing. Now the problem is disk situation after closing , the lines around are not equal and it is not a complete circle , I have tested different boundary and perimeter functions as well as some filters and reconstruction, they did not help . > > if you have some ideas I would be glad to hear them, thank you in advance for your help. You're going to have to show us a picture and give a more detailed description of what you want to to with the closed image. Put the image on a free hosting site.
From: ImageAnalyst on 27 May 2010 13:16 Alex: I don't understand what you're describing. A "dilation" (not delation) followed by an erosion on the output image is the same as a morphological closing operation, which is done by the function "imclose()" of the Image Processing Toolbox. Now, what is this disk you're talking about? The "holes" in your subject (probably not), or the structuring element (probably). Not sure what you mean by "the disk situation after closing." As you know, it's digital so the smaller the disk (circle) is the "chunkier" (more discrete) it will look. A 3 pixel diameter circle will not appear as smooth as a 300 pixel circle. I also do now know what it means when you say that you "have tested different boundary and perimeter functions." No clue at all what this means. Why don't you post an image and some code.
From: Alex on 31 May 2010 09:41 well here I give detaiedl info and some pics, the first picture taken by microscope is shown here: http://i47.tinypic.com/25ztc0x.jpg I am inetersted in locating the hole (here there is only one in center) and then finding its position related to some arbitrary coordiante system and then finding it's diamater and some other parameters. After changing the picture to binary (black and white) in order to prepare for boundary tracing and etc. I reached to this image: http://i49.tinypic.com/6z5ukx.jpg here you can see the codes : I =imread('1n.jpg'); imshow(I) SE=strel('disk',20); level= graythresh(I); % level=0.5; I2=im2bw(I,level); % binary version figure,imshow(I2); b = double(I2) I3=imclose(I2,SE); %background # figure, surf(double(I3(1:8:end,1:8:end))),zlim([0 255]); set(gca,'ydir','reverse'); % background approxiamtion surface [labeled,numObjects] = bwlabel(I3,4); numObjects figure, imshow(labeled); impixelregion graindata = regionprops(labeled,'basic') maxArea = max([graindata.Area]) maxCentroid= max([graindata.Centroid]) maxBoundingBox=max ([graindata.BoundingBox]) biggestGrain = find([graindata.Area]==maxArea) the histogram is shown here as well: http://i46.tinypic.com/2e1ztli.jpg after closing( dilation and the erosion) I have this final picture : http://i49.tinypic.com/10gi80z.jpg Now the question is what can i do to enhance the boundary of this circle and reach a full disk, I have tought maybe the picture quality is poor becasue of illumination or other things.
From: ImageAnalyst on 31 May 2010 15:36 Not sure what your second and third pictures are all about. Why don't you just use standard image processing methods like this that I adapted from my image analysis demo at http://www.mathworks.com/matlabcentral/fileexchange/25157 clc; % Clear the command window. close all; % Close all figures (except those of imtool.) imtool close all; % Close all imtool figures. clear; % Erase all existing variables. workspace; % Make sure the workspace panel is showing. fontSize = 20; % Change the current folder to the folder of this m-file. % (The line of code below is from Brett Shoelson of The Mathworks.) if(~isdeployed) cd(fileparts(which(mfilename))); end folder = 'C:\Documents and Settings\username\My Documents\Temporary stuff'; fullFileName = fullfile(folder, '25ztc0x.jpg'); rgbImage = imread(fullFileName); subplot(2, 2, 1); imshow(rgbImage, []); title('Original RGB Image', 'fontSize', fontSize); % Extract the red channel. grayImage = rgbImage(:,:,1); subplot(2, 2, 2); imshow(grayImage, []); title('Original Grayscale Image', 'fontSize', fontSize); set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full screen. binaryImage = grayImage < 78; subplot(2, 2, 3); imshow(binaryImage, []); title('Binary Image', 'fontSize', fontSize); % Fill holes filledImage = imfill(binaryImage, 'holes'); % Get rid of blobs smaller than 1000 pixels. filledImage = bwareaopen(filledImage, 1000); subplot(2, 2, 4); imshow(filledImage, []); title('Hole Image', 'fontSize', fontSize); [labeledImage numberOfBlobs] = bwlabel(filledImage, 8); % Label each blob so we can make measurements of it % Get all the blob properties. Can only pass in originalImage in version R2008a and later. blobMeasurements = regionprops(labeledImage, grayImage, 'all'); fprintf(1,'Blob # Mean Intensity Area Perimeter Centroid \n'); 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. meanGL = mean(grayImage(thisBlobsPixels)); % Find mean intensity (in original image!) meanGL2008a = blobMeasurements(k).MeanIntensity; % Mean again, but only for version >= R2008a blobArea = blobMeasurements(k).Area; % Get area. blobPerimeter = blobMeasurements(k).Perimeter; % Get perimeter. blobCentroid = blobMeasurements(k).Centroid; % Get centroid. fprintf(1,'#%d %18.1f %11.1f %8.1f %8.1f %8.1f\n', k, meanGL, blobArea, blobPerimeter, blobCentroid); text(blobCentroid(1), blobCentroid(2), num2str(k)); end
|
Next
|
Last
Pages: 1 2 3 Prev: Find repeated elements in different arrays Next: normspec line function |