Extract pixel values from pictures

Hey there Knime community,

First things first, I’m a very bloody beginner at Knime, so I apologize if my question is trivial to most of you.

I’m a student and i have this assignment where I have to take scans of breast cancer and identify the cancer cells through clustering.
I know the first steps i have to take are to:

  • read the image
  • greyscale it
  • turn it into a csv file with the columns being x and y coordinates of the pixels and a numerical value for their color

This way i could visualize the pixel values in a scatter plot that will look like the respective image and then try to analyse it through clustering

The problem is, I don’t know what nodes to use or what kind of extensions i would need for this. Any help in the listed steps as well as ideas for the assignment in general would be greatly appreciated.

Thank you in advance.

Hi @Smegnigma!

no need to apologize! Image processing is not trivial at all.

We had a blog post last year showing an example of how to predict cancer types based on histopathology slices:
https://www.knime.com/blog/using-the-new-knime-deep-learning-keras-integration-to-predict-cancer-type-from-histopathology
The workflows described there can be downloaded from the KNIME Hub here.
Maybe this helps already a bit to start.

Best,
Martyna

3 Likes

I’ll add a little more here,

To the best of my knowledge there is no dedicated node for converting an image to greyscale, but you can apply a custom calculation to do so.

First you would need to split the image into it’s 3 color channels:

Then combine your channels with some math expression:

Finally to get a table you’ll want to play with the:

Here’s an example with the KNIME logo:
image
image

Here’s an example workflow that also converts the image to a table:


6 Likes

Hey Corey,

thank you very much for your input, this really helps.
Is there a way to turn the ouput table into another table which has 3 columns:
x-coordinate of the pixel, y-coordinate of the pixel, greyscale (1-256) value of the pixel.

I’ve been looking for a suitable node that can show me the coordinates of a table cell but couldn’t find one for the life of me.

There’d be some cleaning up to do but using the unpivoting node with a configuration like this would build the kind of table you’re looking for, just apply it to the end of the above example.

3 Likes

So it WAS the Unpivoting node, I just didn’t choose the right settings, god damnit. Again thank you so much. Now to find out how I rename columns and rows. :smiley:

2 Likes

In this case, you won’t necessarily need to transpose your table, so you can gain some performance (in particular for larger and more images) by using the Ungroup node (instead of Transpose and Split Collection Column), as illustrated by the lower branch in this workflow screenshot:

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.