profile_line function

19 views
Skip to first unread message

Jaime Lopez Carvajal

unread,
Feb 23, 2016, 9:33:33 AM2/23/16
to scikit-image
Hi, 

I would like to know why the function profile_line from profile.py in module skimage.measure, always return an additional value (zero value) at the end for horizontal and vertical lines, and two extra values (2 zeros) for diagonal lines.
I mean, if I have an image 10x10, and I want the profile line

> a = profile_line(img, (0, 0), (0, 10))
> array([  83.,   82.,   81.,   88.,   95.,   88.,   93.,  107.,  121.,  146.,    0.])

and with diagonal lines it returns two additional values (2 zeros), like this:

> a = profile_line(img, (0, 0), (10, 10))
> array([  83.,   92.,  105.,  123.,  100.,   69.,   46.,   46.,   48.,   52.,   62.,   70.,   77.,   84.,    0.,    0.])

Thanks in advance for your comments, 

Jaime

Juan Nunez-Iglesias

unread,
Feb 23, 2016, 6:15:31 PM2/23/16
to scikit...@googlegroups.com
Hi Jaime,

It's a bit confusing, but, because profile_line is used in interactive tools, *the final point is included in the line*, unlike normal Python/NumPy indexing. It would be unintuitive in interactive tools *not* to include the final point. (This is in the "Notes" section in the docstring.) So, your final point, (0, 10), is actually outside your image, and the constant value of 0 is returned. I suspect that for your use case you want to call profile_line(img, (0, 0), (0, 9)) and profile_line(img, (0, 0), (9, 9)). I think it should work as expected in those cases.

I hope that helps!

Juan.

--
You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com.
To post to this group, send email to scikit...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/d4e6af4a-b4de-49b1-9e57-6391e17dcb9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jaime Lopez Carvajal

unread,
Feb 23, 2016, 6:40:25 PM2/23/16
to scikit-image
Hi Juan,

I see your point, I read about the difference with Numpy indexing, but I did understand at that time. 
Your explanation is very clear, as well your suggestion about to use the shorter range.
Thanks for your time.

Jaime
Reply all
Reply to author
Forward
0 new messages