Is it possible to save contours to spreadsheet

45 views
Skip to first unread message

Matteo

unread,
Apr 19, 2018, 11:22:59 PM4/19/18
to scikit-image
I am using a modified version of this scikit-image demo to create contours from the edges resulting from watershed segmentation of an image. I would like to save the resulting contours in a spreadsheet, not an image, to take into a GIS package (although I do save image for another application).
I am trying to use Pandas DataFrames as described in this StackOverflow question:
https://stackoverflow.com/questions/49930616/how-to-store-scikit-image-contours-in-a-pandas-dataframe-with-a-single-vertex-an
But I wonder if there's an easier way I overlooked.
Thanks,
Matteo

Juan Nunez-Iglesias

unread,
Apr 20, 2018, 3:48:44 AM4/20/18
to scikit...@googlegroups.com
I would do something along these lines:

frames = []
for contour_id, contour in enumerate(contours):
    current_frame = pd.DataFrame(contour, columns={'row', 'column'})
    current_frame['contour'] = contour_id  # creates column with repeated value
    frames.append(current_frame)

full_data = pd.concat(frames)
--
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.
For more options, visit https://groups.google.com/d/optout.

Matteo Niccoli

unread,
Apr 20, 2018, 9:59:46 AM4/20/18
to scikit...@googlegroups.com
That works very well Juan, thanks so much for answering on SO as well
Matteo

Matteo Niccoli
P. Geo., M.sc.
Geophysics and data science
WordPressLinkedInTwitterCustom linkCustom link

On Fri, Apr 20, 2018 at 1:48 AM, Juan Nunez-Iglesias <jni....@gmail.com> wrote:
I would do something along these lines:

frames = []
for contour_id, contour in enumerate(contours):
    current_frame = pd.DataFrame(contour, columns={'row', 'column'})
    current_frame['contour'] = contour_id  # creates column with repeated value
    frames.append(current_frame)

full_data = pd.concat(frames)


On Fri, Apr 20, 2018, at 1:22 PM, Matteo wrote:
I am using a modified version of this scikit-image demo to create contours from the edges resulting from watershed segmentation of an image. I would like to save the resulting contours in a spreadsheet, not an image, to take into a GIS package (although I do save image for another application).


But I wonder if there's an easier way I overlooked.
Thanks,
Matteo


--
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+unsubscribe@googlegroups.com.
To post to this group, send email to scikit...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "scikit-image" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scikit-image/U1llrbRTVCc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scikit-image+unsubscribe@googlegroups.com.

To post to this group, send email to scikit...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages