From: Lars-Göran Nord on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <77b15315-fe1a-49a4-bec4-450751f27c09(a)l25g2000prn.googlegroups.com>...
> On Aug 1, 4:58 pm, "Lars-Göran Nord" <lars-goran.no...(a)uddeholm.se>
> wrote:
> > >Is this way OK to answer?
> >
> > >Images are now uploaded one tif that I did in photoshop so its not a real image of the cracks but quite close. For the skeletton I used  bw3 = bwmorph(bw2, 'thin', inf);
> >
> > >I hope this will help us both:-)
> >
> > >Thanks for your interest.
> --------------------------------------------------------------------------
> At least you're replying to the proper response so that's good, but
> you're responses still have a > in front of them so they are being
> considered part of the prior reply and don't show up - they're
> collapsed.
>
> Anyway, I did download your image and do a little bit. Your cracks
> are pretty thin - 1.24 pixels wide. Here is the code I used:
> IMPORTANT: YOU WILL HAVE TO JOIN ANY LINES THAT THE NEWS READER SPLITS
> INTO TWO.
> I summed the skeleton to get the total cracks length. Then I divided
> the area by that to get the average width:
>
>
> 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
>
> % Read in a standard MATLAB gray scale demo image.
> folder = 'C:\Documents and Settings\username\My Documents\Temporary
> stuff';
> baseFileName = 'cr1.tif';
> fullFileName = fullfile(folder, baseFileName);
> grayImage = imread(fullFileName);
> % Get the dimensions of the image. numberOfColorBands should be = 1.
> [rows columns numberOfColorBands] = size(grayImage);
> if numberOfColorBands > 1
> % Convert to gray scale
> grayImage = rgb2gray(grayImage);
> end
> % Display the original gray scale image.
> subplot(2, 2, 1);
> imshow(grayImage, []);
> title('Original Grayscale Image', 'FontSize', fontSize);
> set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full
> screen.
>
> binaryImage = grayImage < 100;
> % Display the binary image.
> subplot(2, 2, 2);
> imshow(binaryImage, []);
> title('Binarized Image', 'FontSize', fontSize);
> binaryArea = sum(binaryImage(:))
>
> skel = bwmorph(binaryImage, 'skel');
> % Display the skeletonized image.
> subplot(2, 2, 3);
> imshow(skel, []);
> title('Skeletonized Image', 'FontSize', fontSize);
>
> % Calculate the length of all the cracks.
> skelArea = sum(skel(:))
>
> % Divide the area by the length to get the average width.
> crackWidth = binaryArea / skelArea;
>
> message = sprintf('Done!\nThe area of the cracks is %d\nThe length of
> the cracks is %d\nThe average width of the cracks is %.2f', ...
> binaryArea, skelArea, crackWidth);
> uiwait(msgbox(message));
>
>



Thanks a lot,

I have run the code and get the same answer as you, the lines should be 9 pixels wide as I used that in photoshop when I made this test image (cr1.tif)
Bedtime now will check more tomorrow.

Best regards,
Lars
From: ImageAnalyst on
On Aug 1, 9:50 pm, "Lars-Göran Nord" <lars-goran.no...(a)uddeholm.se>
wrote:
> Thanks a lot,
>
> I have run the code and get the same answer as you, the lines should be 9 pixels wide as I used that in photoshop when I made this test image (cr1.tif)
> Bedtime now will check more tomorrow.
>
> Best regards,
> Lars
-----------------------------------------------------------------------
Lars:
You're right - I forgot that the skel option of bwmorph doesn't
produce the full skeleton unless you add the 'inf' argument:
skel = bwmorph(binaryImage, 'skel', 'inf');

Now it will say 10.17 pixels as the average crack width.
Sorry about that, but it's correct now.
ImageAnalyst
From: Sean on
"Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message <i3588v$j5j$1(a)fred.mathworks.com>...
> ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <77b15315-fe1a-49a4-bec4-450751f27c09(a)l25g2000prn.googlegroups.com>...
> > On Aug 1, 4:58 pm, "Lars-Göran Nord" <lars-goran.no...(a)uddeholm.se>
> > wrote:
> > > >Is this way OK to answer?
> > >
> > > >Images are now uploaded one tif that I did in photoshop so its not a real image of the cracks but quite close. For the skeletton I used  bw3 = bwmorph(bw2, 'thin', inf);
> > >
> > > >I hope this will help us both:-)
> > >
> > > >Thanks for your interest.
> > --------------------------------------------------------------------------
> > At least you're replying to the proper response so that's good, but
> > you're responses still have a > in front of them so they are being
> > considered part of the prior reply and don't show up - they're
> > collapsed.
> >
> > Anyway, I did download your image and do a little bit. Your cracks
> > are pretty thin - 1.24 pixels wide. Here is the code I used:
> > IMPORTANT: YOU WILL HAVE TO JOIN ANY LINES THAT THE NEWS READER SPLITS
> > INTO TWO.
> > I summed the skeleton to get the total cracks length. Then I divided
> > the area by that to get the average width:
> >
> >
> > 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
> >
> > % Read in a standard MATLAB gray scale demo image.
> > folder = 'C:\Documents and Settings\username\My Documents\Temporary
> > stuff';
> > baseFileName = 'cr1.tif';
> > fullFileName = fullfile(folder, baseFileName);
> > grayImage = imread(fullFileName);
> > % Get the dimensions of the image. numberOfColorBands should be = 1.
> > [rows columns numberOfColorBands] = size(grayImage);
> > if numberOfColorBands > 1
> > % Convert to gray scale
> > grayImage = rgb2gray(grayImage);
> > end
> > % Display the original gray scale image.
> > subplot(2, 2, 1);
> > imshow(grayImage, []);
> > title('Original Grayscale Image', 'FontSize', fontSize);
> > set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full
> > screen.
> >
> > binaryImage = grayImage < 100;
> > % Display the binary image.
> > subplot(2, 2, 2);
> > imshow(binaryImage, []);
> > title('Binarized Image', 'FontSize', fontSize);
> > binaryArea = sum(binaryImage(:))
> >
> > skel = bwmorph(binaryImage, 'skel');
> > % Display the skeletonized image.
> > subplot(2, 2, 3);
> > imshow(skel, []);
> > title('Skeletonized Image', 'FontSize', fontSize);
> >
> > % Calculate the length of all the cracks.
> > skelArea = sum(skel(:))
> >
> > % Divide the area by the length to get the average width.
> > crackWidth = binaryArea / skelArea;
> >
> > message = sprintf('Done!\nThe area of the cracks is %d\nThe length of
> > the cracks is %d\nThe average width of the cracks is %.2f', ...
> > binaryArea, skelArea, crackWidth);
> > uiwait(msgbox(message));
> >
> >
>
>
>
> Thanks a lot,
>
> I have run the code and get the same answer as you, the lines should be 9 pixels wide as I used that in photoshop when I made this test image (cr1.tif)
> Bedtime now will check more tomorrow.
>
> Best regards,
> Lars

Can you post the original non-binary crack image that you have? I think that will open up the options that you have.
Thanks
From: Sean on
"Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message
> >Just summing the pixels to get the length from my one pixel line is not sinking in, if I have a 45 deg. line i.e. all pixels connected corner by corner then this will be a quite incorrect method to me?????

It really depends on what your original image looks like. You could systematically calculate the line length finding: corner connected (45deg) pixels, face connected pixels, and boundary pixels (either edge of the image or end of a line). I think that we should look at your original images; however, and there is probably a better way to do it.

First and foremost, I don't know if you're just trying to set up a method for future use or strictly doing analysis on images you already have. Depending on how uniform your images are; if you change your acquisition protocol to get pre and post cracking images it would be a great tool in accurately identifying the cracks.
From: Lars-Göran Nord on
"Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i36fii$ktd$1(a)fred.mathworks.com>...
> "Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message
> > >Just summing the pixels to get the length from my one pixel line is not sinking in, if I have a 45 deg. line i.e. all pixels connected corner by corner then this will be a quite incorrect method to me?????
>
> It really depends on what your original image looks like. You could systematically calculate the line length finding: corner connected (45deg) pixels, face connected pixels, and boundary pixels (either edge of the image or end of a line). I think that we should look at your original images; however, and there is probably a better way to do it.
>
> First and foremost, I don't know if you're just trying to set up a method for future use or strictly doing analysis on images you already have. Depending on how uniform your images are; if you change your acquisition protocol to get pre and post cracking images it would be a great tool in accurately identifying the cracks.


Sean

There is an tif image uploaded (cr1.tif) on drop this is the one I made in photoshop as a test image. The image is close to a real one, but its crack width is evan at 9 pixels normaly the width will vary. I check my sample at specific times and look at crack propagation, trying to compare length, mean width and number of branch points (3 and 4 "crossings").
Pictures will be taken in SEM and then analysed, I'm not sure if I'm allowed to have some other software at the computer running the SEM (scanning electron microscope). So it will probably be post processing of my images.
Not sure if that is what you ment??? At least you know my way of working now.

Regards,
Lars
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10
Prev: Find word in string
Next: starn matlab with crontab