From: Alex on 1 Jun 2010 08:55 Thanks for your suggestion I have tried your program. There is still a problem,I am working on hole identification in range of mm-um. for this mean even with high resolutuion cameras I could not reach a photo like yours, I mean your example is a little more advanced than IPT manual but still the picture is from coins and it is taken vertical to surface, but in my case because of some issues with machine ( measuring machine ) the working space is limited and the picture is taken with an angle of 35-45 to the surface from this view its doesn' look like a circle. Unfortunately I could not find examples similar to this situation, the next picture shows the latest photo that I have taken and I hope it helps to understanding the situation better. http://i49.tinypic.com/wahd8m.jpg If you have a suggestion please share it with me.
From: ImageAnalyst on 1 Jun 2010 10:14 If you'll notice, the code I posted in the newsgroup actually DID use the exact image that you uploaded, as opposed to the File Exchange demo which uses the coins image . And it did a respectable job on your image. Now the additional picture you uploaded might possibly be able to be solved with the same script, or some simple modifications, but I can't tell because you didn't upload it as an individual photo - it's combined with figures and I didn't feel like going to the work of cropping and saving the relevant portion. Overall, this does not look like a very tough problem to solve. The hardest part may be getting real world units out of it since in this photo, it looks like your image is sheared because the camera was looking at it with an oblique angle. -ImageAnalyst
From: Alex on 3 Jun 2010 12:00 yeah, I have checked your program, I appreciate it ! Now what can I do with the edges of the hole to reach a complete disk and later with help of the world coordinate system locate the hole position and measure it's properties with high precision, as I told earlier it's gonna use in a mm-um range so it should be very exact. I think the problem is more serious with oblique angles. That was my problem since beginning of this topic.
From: Alex on 4 Jun 2010 08:39 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 = 'K:\Haus\mlm-ad'; 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); %-------------------------------------------------------------------------- % added for determining the boundary of the main hole hold on; boundaries = bwboundaries(filledImage); numberOfBoundaries = size(boundaries); for k = 1 : numberOfBoundaries thisBoundary = boundaries{k}; plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2); end hold off; %BW=edge(grayImage,'canny') %figure,imshow(BW); % end of added part [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 total=bwarea(filledImage) ************************************** this one is your code with a litte change , this results appears in command window: Blob # Mean Intensity Area Perimeter Centroid #1 69.6 3754.0 314.8 310.8 236.4 total Area form 2nd method= 3.7696e+003 Now if I calculate the radius from the perimeter or Area , they are not equal : one is 34,56 & the other is 50,1 becasue it is not a real circle, I think of another algorithm to calculate the radius in 360° and then take the integral and finally calculate the mean value, yet I am not aware of its talorance and deviation by using this method. for the new photo the situation is similar, only the positioning is a little though. better ideas are warmly appreciated! Alex
From: ImageAnalyst on 4 Jun 2010 11:11 Alex: To get the "true" diameter, you think you'd have to know the angle that the circle is tilted at when you're viewing it. But maybe there's a way around it. No matter how you tilt a circle, the maximum extent along the ellipse will be the circle diameter. So just go with that. Detect the ellipse, and then use the MajorAxisLength as returned by regionprops. ImageAnalyst
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Find repeated elements in different arrays Next: normspec line function |