From: Lars-Göran Nord on
"Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i36qv1$jm5$1(a)fred.mathworks.com>...
> "Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message <i36p29$e2f$1(a)fred.mathworks.com>...
> > "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i36l3e$l15$1(a)fred.mathworks.com>...
> > > "Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message
> > >
> > > > There is an tif image uploaded (cr1.tif) on drop this is the one I made in photoshop as a test image.
> > > Oh sorry, I thought that 'binarized'
> > >
> > > 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.
> > >
> > > The image analysis will always be post-processing but what I was hoping for is that you could have a series of images, exactly as you have said, where there are different levels of crack propagation. If the camera and beam (?) are fixed, you should be able to measure the difference by a simple subtraction. I.e. the first image has no cracks; the second one has a little bit (total area would be the sum, average area we're still working on; number of crack sprouts is a difficult problem but is doable if you want it.) Then the next (3rd image) would subtract the 2nd image to see where new cracks have spouted and where certain cracks have expanded (or contracted). As far as the average area; I think using perimeter/2 could be dangerous; especially if the cracks become wider. If you imagine a perfect rectangle of size 3x2 and do the math it, you'll see why.
> > >
> > > ImageAnalyst's way with the skeleton and then predefined lengths for different pixel connectivities is probably best.
> > >
> > > Another way you could get length, depending on how much time you want to devote to this, would be to calculate the orientation at each point and then figure out how long the line segment through that pixel would be at that orientation. (You might want to hear someone else reassure me on that! :)
> > > The advantage of calculating the orientation at each point is that it would help you later with calculating number of cracks, since there is a major change in orientation where crack sprouts diverge from the bigger cracks.
> >
> > I fully agree to your comments and analysing cracks as you mentioned is great.
> > Calculating the orientation looks like a great thing to do but your comment "(You might want to hear someone else reassure me on that! :) is that one regarding the very good function or about the loooong time involved:-)
> >
> > Lars
>
> Hi Lars,
>
> I just think that it would be good to hear a second opinion on the orientation as a means of finding length idea before you spend too much time on it. I've given it a little more thought and I think it would be accurate. Consider this: a pixel is a square with the origin in the bottom left corner and a pixel orientation i.e. the orientation, theta, that this pixel has relative to what's around it. A few examples:
> -if theta is 45deg; distance = 1/cos(45)= sqrt(2)=1.414; diagonal
> -if theta is 0deg from either the vertical or horizontal axis = 1/cos(0) = 1; one side length
> -if theta is 35deg from either vertical or horizontal axis 1/cos(35);
> So 1/cos(theta) with each theta being the smallest angle from _any_ horizontal or vertical axis (i.e. always <= 45deg) would give the traversal of a line across this pixel. Then the sum of these would be the length. These calculations would be run on your skeleton.
>
> Using orientation to calculate sprouts (or to segment fibers, veins etc.) is pretty well documented. Though many "Number of crack" measurements are actually "Number of new objects" measurements. I.e. they calculate the number of objects created rather than the number of cracks. Thus a crack really only counts when it creates a new object. Just a few thoughts for you to toy with!
>
> -Sean

Hi Sean,
The "orientation" way is very tempting as it can be developed further as you mentioned, well to me it is the right way to go!
Well the crack talk is OK but to me crack width is also very important as its kind of a inderect measurement of crack depth in the steel. And at a specific crack depth you get total failure of the part.

Lars
From: Lars-Göran Nord on
"Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i36qv1$jm5$1(a)fred.mathworks.com>...
> "Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message <i36p29$e2f$1(a)fred.mathworks.com>...
> > "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i36l3e$l15$1(a)fred.mathworks.com>...
> > > "Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message
> > >
> > > > There is an tif image uploaded (cr1.tif) on drop this is the one I made in photoshop as a test image.
> > > Oh sorry, I thought that 'binarized'
> > >
> > > 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.
> > >
> > > The image analysis will always be post-processing but what I was hoping for is that you could have a series of images, exactly as you have said, where there are different levels of crack propagation. If the camera and beam (?) are fixed, you should be able to measure the difference by a simple subtraction. I.e. the first image has no cracks; the second one has a little bit (total area would be the sum, average area we're still working on; number of crack sprouts is a difficult problem but is doable if you want it.) Then the next (3rd image) would subtract the 2nd image to see where new cracks have spouted and where certain cracks have expanded (or contracted). As far as the average area; I think using perimeter/2 could be dangerous; especially if the cracks become wider. If you imagine a perfect rectangle of size 3x2 and do the math it, you'll see why.
> > >
> > > ImageAnalyst's way with the skeleton and then predefined lengths for different pixel connectivities is probably best.
> > >
> > > Another way you could get length, depending on how much time you want to devote to this, would be to calculate the orientation at each point and then figure out how long the line segment through that pixel would be at that orientation. (You might want to hear someone else reassure me on that! :)
> > > The advantage of calculating the orientation at each point is that it would help you later with calculating number of cracks, since there is a major change in orientation where crack sprouts diverge from the bigger cracks.
> >
> > I fully agree to your comments and analysing cracks as you mentioned is great.
> > Calculating the orientation looks like a great thing to do but your comment "(You might want to hear someone else reassure me on that! :) is that one regarding the very good function or about the loooong time involved:-)
> >
> > Lars
>
> Hi Lars,
>
> I just think that it would be good to hear a second opinion on the orientation as a means of finding length idea before you spend too much time on it. I've given it a little more thought and I think it would be accurate. Consider this: a pixel is a square with the origin in the bottom left corner and a pixel orientation i.e. the orientation, theta, that this pixel has relative to what's around it. A few examples:
> -if theta is 45deg; distance = 1/cos(45)= sqrt(2)=1.414; diagonal
> -if theta is 0deg from either the vertical or horizontal axis = 1/cos(0) = 1; one side length
> -if theta is 35deg from either vertical or horizontal axis 1/cos(35);
> So 1/cos(theta) with each theta being the smallest angle from _any_ horizontal or vertical axis (i.e. always <= 45deg) would give the traversal of a line across this pixel. Then the sum of these would be the length. These calculations would be run on your skeleton.
>
> Using orientation to calculate sprouts (or to segment fibers, veins etc.) is pretty well documented. Though many "Number of crack" measurements are actually "Number of new objects" measurements. I.e. they calculate the number of objects created rather than the number of cracks. Thus a crack really only counts when it creates a new object. Just a few thoughts for you to toy with!
>
> -Sean

I have to ask one more thing, 35 deg ? then we must look at pixels further away then closest ones right!

Thanks,
Lars
From: Sean on
"Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message <i37hjs$nek$1(a)fred.mathworks.com>...
> "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i36qv1$jm5$1(a)fred.mathworks.com>...
> > "Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message <i36p29$e2f$1(a)fred.mathworks.com>...
> > > "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i36l3e$l15$1(a)fred.mathworks.com>...
> > > > "Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message
> > > >
> > > > > There is an tif image uploaded (cr1.tif) on drop this is the one I made in photoshop as a test image.
> > > > Oh sorry, I thought that 'binarized'
> > > >
> > > > 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.
> > > >
> > > > The image analysis will always be post-processing but what I was hoping for is that you could have a series of images, exactly as you have said, where there are different levels of crack propagation. If the camera and beam (?) are fixed, you should be able to measure the difference by a simple subtraction. I.e. the first image has no cracks; the second one has a little bit (total area would be the sum, average area we're still working on; number of crack sprouts is a difficult problem but is doable if you want it.) Then the next (3rd image) would subtract the 2nd image to see where new cracks have spouted and where certain cracks have expanded (or contracted). As far as the average area; I think using perimeter/2 could be dangerous; especially if the cracks become wider. If you imagine a perfect rectangle of size 3x2 and do the math it, you'll see why.
> > > >
> > > > ImageAnalyst's way with the skeleton and then predefined lengths for different pixel connectivities is probably best.
> > > >
> > > > Another way you could get length, depending on how much time you want to devote to this, would be to calculate the orientation at each point and then figure out how long the line segment through that pixel would be at that orientation. (You might want to hear someone else reassure me on that! :)
> > > > The advantage of calculating the orientation at each point is that it would help you later with calculating number of cracks, since there is a major change in orientation where crack sprouts diverge from the bigger cracks.
> > >
> > > I fully agree to your comments and analysing cracks as you mentioned is great.
> > > Calculating the orientation looks like a great thing to do but your comment "(You might want to hear someone else reassure me on that! :) is that one regarding the very good function or about the loooong time involved:-)
> > >
> > > Lars
> >
> > Hi Lars,
> >
> > I just think that it would be good to hear a second opinion on the orientation as a means of finding length idea before you spend too much time on it. I've given it a little more thought and I think it would be accurate. Consider this: a pixel is a square with the origin in the bottom left corner and a pixel orientation i.e. the orientation, theta, that this pixel has relative to what's around it. A few examples:
> > -if theta is 45deg; distance = 1/cos(45)= sqrt(2)=1.414; diagonal
> > -if theta is 0deg from either the vertical or horizontal axis = 1/cos(0) = 1; one side length
> > -if theta is 35deg from either vertical or horizontal axis 1/cos(35);
> > So 1/cos(theta) with each theta being the smallest angle from _any_ horizontal or vertical axis (i.e. always <= 45deg) would give the traversal of a line across this pixel. Then the sum of these would be the length. These calculations would be run on your skeleton.
> >
> > Using orientation to calculate sprouts (or to segment fibers, veins etc.) is pretty well documented. Though many "Number of crack" measurements are actually "Number of new objects" measurements. I.e. they calculate the number of objects created rather than the number of cracks. Thus a crack really only counts when it creates a new object. Just a few thoughts for you to toy with!
> >
> > -Sean
>
> I have to ask one more thing, 35 deg ? then we must look at pixels further away then closest ones right!
>
> Thanks,
> Lars

Yes. Consider this case:
%%% Philosophical Image
M = false(8); %Binary Image
M(5,4) = true;
M(4,4) = true;
M(3,5) = true;
M(2,5) = true;
M(6,3) = true;
M(7,3) = true;
imtool(M) %Look at image (zoom in)
%%%
Now, (I didn't realize this but it greatly simplifies your problem) since this is all 2-dimensional, you have the luxury of using the 'Orientation' option of regionprops(). I would, to start at least, use two pixels on each side. Here's a quick example of how that works:
%%%
CC = bwconncomp(M);
my_orientation = regionprops(CC,'Orientation');
%%%
%
%my_orientation = 1x1 struct
%my_orientation =
% Orientation: 65.0780
%Thus the angle you would use:
%90-my_orientation.Orientation
% ans = 24.9220
%length = 1/cosd(ans); %= 1.1027
%
From: Lars-Göran Nord on
"Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i395dd$a33$1(a)fred.mathworks.com>...
> "Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message <i37hjs$nek$1(a)fred.mathworks.com>...
> > "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i36qv1$jm5$1(a)fred.mathworks.com>...
> > > "Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message <i36p29$e2f$1(a)fred.mathworks.com>...
> > > > "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i36l3e$l15$1(a)fred.mathworks.com>...
> > > > > "Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message
> > > > >
> > > > > > There is an tif image uploaded (cr1.tif) on drop this is the one I made in photoshop as a test image.
> > > > > Oh sorry, I thought that 'binarized'
> > > > >
> > > > > 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.
> > > > >
> > > > > The image analysis will always be post-processing but what I was hoping for is that you could have a series of images, exactly as you have said, where there are different levels of crack propagation. If the camera and beam (?) are fixed, you should be able to measure the difference by a simple subtraction. I.e. the first image has no cracks; the second one has a little bit (total area would be the sum, average area we're still working on; number of crack sprouts is a difficult problem but is doable if you want it.) Then the next (3rd image) would subtract the 2nd image to see where new cracks have spouted and where certain cracks have expanded (or contracted). As far as the average area; I think using perimeter/2 could be dangerous; especially if the cracks become wider. If you imagine a perfect rectangle of size 3x2 and do the math it, you'll see why.
> > > > >
> > > > > ImageAnalyst's way with the skeleton and then predefined lengths for different pixel connectivities is probably best.
> > > > >
> > > > > Another way you could get length, depending on how much time you want to devote to this, would be to calculate the orientation at each point and then figure out how long the line segment through that pixel would be at that orientation. (You might want to hear someone else reassure me on that! :)
> > > > > The advantage of calculating the orientation at each point is that it would help you later with calculating number of cracks, since there is a major change in orientation where crack sprouts diverge from the bigger cracks.
> > > >
> > > > I fully agree to your comments and analysing cracks as you mentioned is great.
> > > > Calculating the orientation looks like a great thing to do but your comment "(You might want to hear someone else reassure me on that! :) is that one regarding the very good function or about the loooong time involved:-)
> > > >
> > > > Lars
> > >
> > > Hi Lars,
> > >
> > > I just think that it would be good to hear a second opinion on the orientation as a means of finding length idea before you spend too much time on it. I've given it a little more thought and I think it would be accurate. Consider this: a pixel is a square with the origin in the bottom left corner and a pixel orientation i.e. the orientation, theta, that this pixel has relative to what's around it. A few examples:
> > > -if theta is 45deg; distance = 1/cos(45)= sqrt(2)=1.414; diagonal
> > > -if theta is 0deg from either the vertical or horizontal axis = 1/cos(0) = 1; one side length
> > > -if theta is 35deg from either vertical or horizontal axis 1/cos(35);
> > > So 1/cos(theta) with each theta being the smallest angle from _any_ horizontal or vertical axis (i.e. always <= 45deg) would give the traversal of a line across this pixel. Then the sum of these would be the length. These calculations would be run on your skeleton.
> > >
> > > Using orientation to calculate sprouts (or to segment fibers, veins etc.) is pretty well documented. Though many "Number of crack" measurements are actually "Number of new objects" measurements. I.e. they calculate the number of objects created rather than the number of cracks. Thus a crack really only counts when it creates a new object. Just a few thoughts for you to toy with!
> > >
> > > -Sean
> >
> > I have to ask one more thing, 35 deg ? then we must look at pixels further away then closest ones right!
> >
> > Thanks,
> > Lars
>
> Yes. Consider this case:
> %%% Philosophical Image
> M = false(8); %Binary Image
> M(5,4) = true;
> M(4,4) = true;
> M(3,5) = true;
> M(2,5) = true;
> M(6,3) = true;
> M(7,3) = true;
> imtool(M) %Look at image (zoom in)
> %%%
> Now, (I didn't realize this but it greatly simplifies your problem) since this is all 2-dimensional, you have the luxury of using the 'Orientation' option of regionprops(). I would, to start at least, use two pixels on each side. Here's a quick example of how that works:
> %%%
> CC = bwconncomp(M);
> my_orientation = regionprops(CC,'Orientation');
> %%%
> %
> %my_orientation = 1x1 struct
> %my_orientation =
> % Orientation: 65.0780
> %Thus the angle you would use:
> %90-my_orientation.Orientation
> % ans = 24.9220
> %length = 1/cosd(ans); %= 1.1027
> %


Thank you Sean,

I will look deeper into this this evening, as I'm not an expert in this it takes some time for me to figure it all out:-)
Do you think I can solve all this with some help:-) I have to tell my boss this monday if its possible or not. Othervise they will outsorce the whole thing, and I really dont like that at all. And the pleasure of success is aalso very sweet:-)

Thanks again,
Lars
From: Sean on
"Lars-Göran Nord" <lars-goran.nordh(a)uddeholm.se> wrote in message
> Thank you Sean,
>
> I will look deeper into this this evening, as I'm not an expert in this it takes some time for me to figure it all out:-)
> Do you think I can solve all this with some help:-) I have to tell my boss this monday if its possible or not. Othervise they will outsorce the whole thing, and I really dont like that at all. And the pleasure of success is aalso very sweet:-)
>
> Thanks again,
> Lars

You're welcome!

It's definitely doable and I think you're close to the solution. The programming aspects of this shouldn't be too hard as you have the aid of the Image Processing Toolbox.

Global approach:
-Create the skeleton with the aid of Image Analyst's example
-Calculate the orientation at each point on the skeleton using the bwconncomp, regionprops functions.
-To get length across pixel use the approach I gave you from above (total line length).
-To get max crack width: at each skeleton point calculate the angle orthogonal to that point's orientation. Using this orientation figure out how many point lie along a line drawn at this angle. Use the cos()^-1 formula to get this width too. The only time this would falter would be at intersections.

%%%
%Here is the code to do the first 3 steps in one shot. I think you'll like the results!
%%%
%
%SCd 08/03/2010
%% Load and Binarize
I = imread('/Users/Userx/Downloads/cr1.tif');
I = I(:,:,1) < 52; %Binarize
I = padarray(I,[2 2],false,'both'); %Pad the array for later use
%% ImageAnalyst's Skeleton

skel = bwmorph(I, 'skel',inf);
% Display the skeletonized image.
imtool(skel);

% Calculate total crask
binaryArea = sum(I(:));

% Calculate the length of all the cracks.
skelArea = sum(skel(:));

% Divide the area by the length to get the average width.
mean_crackWidth1 = binaryArea / skelArea

%% Get Orientation at each point

my_orientations = zeros(size(I)); %Preallocate
[r c] = find(skel); %[row col] indices of points on skel
%Note: This is why we padded earlier:
% all r,c are greater>=3 and <= size(dim) -2

%Go to each point and calculate orientation
for ii = 1:length(r)
%Extract all pixels within the 5x5 window surrounding our point
SKpart = skel((r(ii)-2):(r(ii)+2),(c(ii)-2):(c(ii)+2));

%Connected components analysis, 8 connectivity (we care about corners!)
CC =bwconncomp(SKpart,8);

%Get orientation.
RP = regionprops(CC,'Orientation');

%Save the orientation. This may need modified if there are multiple
%Orientations returned in the even of more than one object
my_orientations(r(ii),c(ii)) = RP.Orientation;
end

%Sign doesn't matter
length_orientations = abs(my_orientations);

%Get angle closest to any axis
length_orientations(length_orientations>45) = 90 - length_orientations(length_orientations>45);

%Get length, preserving only those in the skeleton
eachLength = 1./cosd(length_orientations).*double(skel);
skelLength = sum(eachLength(:));

%Crack area divided by length
mean_crackWidth2 = binaryArea/skelLength

%Compare to Image Analyst's:
mean_crackWidth1/mean_crackWidth2
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