Reading grayscale image from CSV

Hi All,

I have a csv file with flattened out grayscal images (one per each row). Each column contains a single pixel. 

I can read the file with a CSV reader, but I cannot find a method to convert it to a format that can be fed into "Image Features" node. 

Is there a way to do this?

 

Thanks,

Hi Tahir,

unfortunately, I suspect that there is no such node to do that, so far.

But adding a node that converts a row of double values into images is quite straightforward and  quickly implemented. So if you don't mind to wait one to three weeks, we'll be happy to provide you with that node (which will than be available on the nightly-build update-site of the community contributions).

As soon the node is ready, I'll post it here.

Best,

Martin

Hi Tahir,

as Martin pointed out we don't have a nice way to do that, anyway you can have the funcationality using a little workaround:

Steps:

1. Install the ImageJ/ImageJ2 Extension from our stable update-site

see step 2.2. : http://tech.knime.org/wiki/install-knime-image-processing

2. Import the example workflow attached to this post. We make use of the IJ1 Macro Node to read in you data. Double Click on the IJ2 Macro node (or right click -> configure) and adjust the path to the file you want to read in. Addtionally you have to configure the size of the image you want to read in in the image generator (here it set it to x=256/y=256). The rest of the Image Generator Node configuration should stay the same.

I know this workaround is a little weird, but better than nothing ;-)

 

Hope this helps,

Christian

PS: I also attached the example csv file I used which is of size (256/256)

 

Thanks Christian

I'll try the workaround that you have provided. 

Once Martin posts his node, I can switch to that. 

Thanks,

Tahir

Hi Christian,

I just checked the workflow you provided, but doesn't seems to be importing images from CSV. Instead it seems to be generating images and then exporting them as Text Image. 

What I want to do is to read in images present in a CSV file (one image per row) and then feed them to Image Features node. 

 

Thanks

Tahir

Hi Tahir,

the workflow is doing what you want, but it's a little tricky (as this is a workaround) ;-)

The steps are:

1. Use the "Image Generator" to create an arbitrary image of the same size as the image in the csv (in the demo case this is 256width and 256height, Right Click on the node -> Configure). The rest of the settings should stay the same. I just need to create this "random" image, to use the ImageJ Macro Node.

2. Right click on "ImageJ Macro" -> Configure. Adjust the "file = ..." variable to point on your csv file. in my case the path was "c:\\myfile.csv" as my csv file is located on c:\\. 

I hope this helps, if it doesn't, you can upload your csv file and I will read it in for you with the workflow and upload it again. 

Cheers,

Christian

Hi Tahir, one more comment:

If you have one image per csv file (row), my workflow doesn't work. Its supposing, that you have one image per csv file. Anyway, I guess Martin added the required node to the current nightly build of our plugin. So if you update KNIME Image Processing using the Nightly Build update-site http://tech.knime.org/update/community-contributions/trunk you simply can use the file reader and the new node (DataRow to Image Converter) which converts one row to an image.

 

Cheers,

Christian

 

Hi Tahir,

the new node is implemented and should be available via the nigthly-build update-site as Christian pointed out. Please note that you have to convert the row of values (e.g. DoubleCells) into a Collection Column first using the "Create Collection Column"-node.

Best,

Martin

Thanks Martin. 

Do you have an example workflow for the new node?

 

Regards

Tahir

Sure.

Martin,

I updated KNIME and used the "Data Row to Image" node and it works fine.

 

Thanks

Tahir