cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
bdeppa
Level II

Converting images in a Data Type: Expression column to RGB and HLS values?

I have read 350 .jpeg images into a JMP data table with the actual images in an Expression column.   Can I then use Image Processing (e.g John Ponte script) on the images contained in the expression column?

4 REPLIES 4
vince_faller
Super User (Alumni)

Re: Converting images in a Data Type: Expression column to RGB and HLS values?

Do you need the interactivity?  The expr() column should just be char to blob() or something (if I remember right), so all the information should be there.

If you edit John P's awesome image analyzer to pick a row (or named row by column or something), it should work just the same. If you need help with this, let me know.  I've played with his script pretty extensively. 

Vince Faller - Predictum
bdeppa
Level II

Re: Converting images in a Data Type: Expression column to RGB and HLS values?

Ideally I would like to obtain a separate data table with the RGB and HLS values for each of the 350 .jpeg images in the Expression column. I found script for reading in multiple .jpeg files from a folder and Image Processing each but I was not able to get it to work. I was able to read the 350 images into one JMP table using the Expression data type, so I was wondering if I could image process directly the images in that column.

And yes the images are Char to Blob () with lots of jibberish between the parentheses.

Thanks in advance for your help,

Brant

vince_faller
Super User (Alumni)

Re: Converting images in a Data Type: Expression column to RGB and HLS values?

If all you need is a data table for each image and not the interactivity of his window.  This should work. 

//Edit of John Ponte's image analyzer

dt = current data table();

nr = nrows(dt);

image_col = Column(dt, "Image");

for(i=1, i<=nr, i++,

       img = image_col;

       {r,g,b} = img << Get Pixels("rgb");

       numRows = nrow(r);

       numCols = ncol(r);  

       // Check for gray scale image

       grayScale = AND( All(r==g), All(g==b) );

      

       if (grayScale,

              // r, g, b are all the same, so that is the intensity.

              // hue and sat are 0 (no color) and luminance is the same as the intensity.

              intensity = r;

             

              dt_Ref = New Table("Reference Data",

                     newColumn("X", set values(repeat(1::numCols, numRows))),

                     newColumn("Y", set values(shape(repeat(1::numRows,numCols)`,numCols,numRows))),

                     newColumn("I", set values(intensity)),

              );

       ,

              // Convert rgb to gray-scale (intensity) matrix

              intensity = 0.3*r + 0.59*g + 0.11*b;

              // Get the pixel values as JSL colors then convert to hue, lightness and saturation

              // HLS colors are in normalized color space (0.0-1.0)

              jslColors = img << getPixels();

              {h, l, s} = ColorToHLS(jslColors);

              dt = New Table("Table "||Char(i),

                     newColumn("X", set values(repeat(1::numCols, numRows))),

                     newColumn("Y", set values(shape(repeat(1::numRows,numCols)`,numCols,numRows))),

                     newColumn("R", set values(r)),

                     newColumn("G", set values(g)),

                     newColumn("B", set values(b)),

                     newColumn("I", set values(intensity)),

                     newColumn("H", set values(h*360)),

                     newColumn("L", set values(l)),

                     newColumn("S", set values(s)),

              );

       );

);

Vince Faller - Predictum
JohnPonte
Staff (Retired)

Re: Converting images in a Data Type: Expression column to RGB and HLS values?

I love the idea of reading the images directly from the data column so I just modified the Image Analyzer and created the Image Column Analyzer​. It  works like the Image Analyzer except instead of choosing an image file you can choose your data table that contains the images. You can cycle through the images and create a data table for any image you want.

I was also going to give you a script that would do the same thing (more automated, no interactivity) but it looks like vince.faller0​ beat me to it.

Enjoy!