Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
problem improfile, imprecise line length

Subject: problem improfile, imprecise line length

From: jayal

Date: 14 Nov, 2011 16:06:30

Message: 1 of 2

I need some help using improfile multiplie times in one image.
Sample image is here:
What you see is some grayscale image of a filament on a dark background.
I did manage to
a) get the skeleton/backbone (binary of original with bwmorph thinning/skeletonize)
b) fit a spap2 spline to it (blue line)
c) do the derivation of the spline to
d) get tangential vectors along the contour (red arrows)
e) get the orthogonal vectors on the tangents (green arrows)
f) and plot lines (yellow) indicating the range improfile uses to determine the intensity values along that line

However I have trouble to use these extracted profiles. Imagine I want to extract the profiles and basically fit a gaussian to them, so I can determine the FWHM of the original grayscale filament orthogonal to its contour/backbone.

Right now I use:
 [xline{i}, yline{i}, grayvalue{i}]= improfile(SUM, [(x(i)-dy(i)*sf) (x(i)+dy(i)*sf)], [(y(i)+dx(i)*sf) (y(i)-dx(i)*sf)], 50,'bicubic');

So I have some points P along the contour with coords x/y and the derrivative dx/dy to get the the direction of the orthogonal vector. I introduced some scaling factor sf to actually seperate start and end point from each other (as improfile needs exact start and end points and not only a direction (correct?)).
Problem is now (I think so):
every line to extract the profiles has a different length (as I have some abitrary angles and I guess not all start end points fall in the normal rasterization), improfile does some equally spacing of the points where to extract the intensity (correct?), so I never end up with values which are comparable or usable in terms of 1px (1 spacing unit) corresponds to lets say 50nm.
I can't manage/don't find a way to force improfile to use "normal" spacing between the points along the line. The length of the line could differ from line to line (I don't care much how long an individual extraction path is) if the spacing is equal.
But vice versa, is it possible to fix the length of the extracting lines so I end up with all profiles being the same length, knowing how many points on the lines are etc. ? (if that is even the better idea..?)
Thought about some euclidian distance, and a routine to "round" the start end points to the next possible value with that given length.. (I guess that would still give some error / if I want to use that fixed length, as it can't be realized in a rastered image with all abitrary angles I need to use)

Maybe someone has some input.
Thanks for your time to read this.

Subject: problem improfile, imprecise line length

From: Ashish Uthama

Date: 14 Nov, 2011 19:11:13

Message: 2 of 2

Both your stated assumptions are correct.
(I am not sure I fully understand, so if anything does not make sense, post back.)
You could ensure a specific equal spacing (d) between the returned profile points by specifying the number of points N (you used 50 above) as:
 N = sum of euclidean distance between line segments which make up the input line / d.
Though, there will be accuracy issues since N has to be an integer.
To ensure that *both* N and the spacing (d) remain the same for each of the profiles, you would have to ensure that the euclidean distance between the start and the end points remain the same (as you note). From what I understand of your code, shouldnt it this distance between the start and end points of one yellow line be the same? (or maybe dx and dy need normalizing?).

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us