cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
WebDesignesCrow
Super User

How to close multiple images loaded after obtain the data table using JSL

Hi,

 

I'm analyzing 6 images using JMP with script by converting the images into data table.

I've concatenated all the images values into 1 data table.

 

The issue is, I can close the previous image data table with Close( Data Table( Tables[i] ), No Save );

But I can't close the 6 images.

I tried something like Close(img) or Close("image") but it won't close. 

Any idea how to close the images in script?

WebDesignesCrow_0-1666924345277.png

 

NamesDefaultToHere(1);
// Read the image1:RED into JMP
img = NewImage("$Capillary Photo 2\RED.jpg");
w = newWindow("image", img);
// Get the pixel values as 3 distinct matrices (red, green and blue)
// RGB colors are in normalized color space (0.0-1.0)
{r, g, b} = img << getPixels("rgb");
// Convert rgb to gray-scale (intensity) matrix
i = 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);
// Get the dimensions of the image/matrices
numRows = nrow(r);
numCols = ncol(r);
// Create a data table
dt1 = New Table("Image Data Red",
	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(i)),
	newColumn("h", set values(h)),
	newColumn("l", set values(l)),
	newColumn("s", set values(s)),
	newColumn("CapillaryType", character, set each value("RED"))
);
img2 = NewImage("$\Capillary Photo 2\BLUE.jpg");
w2 = newWindow("image", img2);
//Some of other parts of script omitted (repetitive)
//Concatenation All Tables into 1
// Create your Tables list
Tables = {};
For( i = 1, i <= N Table(), i++,
	Insert Into( Tables, Data Table( i ) << get name );
);
new Table("Image Data AllColour");
// Run the concatinations table
For( i = 1, i <= N Items( Tables ), i++,
	 Data Table( "Image Data AllColour" ) << Concatenate(
		Data Table( Tables[i] ),
		append to first table(1)
	);
	Close( Data Table( Tables[i] ), No Save );
);
Wait(0);
//the image objects still exist 
//show(img);
//show(img2,3,4,5,6);
img = empty();
img2 = empty();
img3 = empty();
img4 = empty();
img5 = empty();
img6 = empty();
show(img, img2, img3, img4, img5, img6); //see LOG: img = Empty(); img2 = Empty();
delete symbols({img, img2, img3, img4, img5, img6});
show symbols();
Close(img);

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: How to close multiple images loaded after obtain the data table using JSL

Something like this should get you what you want, to close the image windows.

i = 1;
While( Window( i ) << get window title != "",
	If( Left( Window( 1 ) << get window title, 5 ) == image,
		Window( i ) << close window
	);
	i++;
);
Jim

View solution in original post

Jeff_Perkinson
Community Manager Community Manager

Re: How to close multiple images loaded after obtain the data table using JSL

Expanding on @txnelson's solution:

The message you're looking for is  << Close Window pointed at your window reference. In your code you're assign these references to w and w2, so you would send << Close Window to those objects.

 

 

Names Default To Here( 1 );
// Read the image1:RED into JMP
img = New Image( "$Capillary Photo 2\RED.jpg" );
w = New Window( "image", img );
Wait( 5 );
w << close window;

Additionally, it's worth noting that you don't need to display the images in a window to get the pixels.

 

 

 

Names Default To Here( 1 );
image = New Image( "$SAMPLE_IMAGES/windmap.png" );

{r, g, b} = image << getPixels("rgb");

show(r);

 

Similarly, you could avoid displaying the intermediate data tables by making them Private:

dt1 = New Table("Image Data Red",
	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(i)),
	newColumn("h", set values(h)),
	newColumn("l", set values(l)),
	newColumn("s", set values(s)),
	newColumn("CapillaryType", character, set each value("RED")),
	Private // no display window is created; when dt1 is assigned something else the data table will be destroyed
);



 

-Jeff

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: How to close multiple images loaded after obtain the data table using JSL

Something like this should get you what you want, to close the image windows.

i = 1;
While( Window( i ) << get window title != "",
	If( Left( Window( 1 ) << get window title, 5 ) == image,
		Window( i ) << close window
	);
	i++;
);
Jim
Jeff_Perkinson
Community Manager Community Manager

Re: How to close multiple images loaded after obtain the data table using JSL

Expanding on @txnelson's solution:

The message you're looking for is  << Close Window pointed at your window reference. In your code you're assign these references to w and w2, so you would send << Close Window to those objects.

 

 

Names Default To Here( 1 );
// Read the image1:RED into JMP
img = New Image( "$Capillary Photo 2\RED.jpg" );
w = New Window( "image", img );
Wait( 5 );
w << close window;

Additionally, it's worth noting that you don't need to display the images in a window to get the pixels.

 

 

 

Names Default To Here( 1 );
image = New Image( "$SAMPLE_IMAGES/windmap.png" );

{r, g, b} = image << getPixels("rgb");

show(r);

 

Similarly, you could avoid displaying the intermediate data tables by making them Private:

dt1 = New Table("Image Data Red",
	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(i)),
	newColumn("h", set values(h)),
	newColumn("l", set values(l)),
	newColumn("s", set values(s)),
	newColumn("CapillaryType", character, set each value("RED")),
	Private // no display window is created; when dt1 is assigned something else the data table will be destroyed
);



 

-Jeff
WebDesignesCrow
Super User

Re: How to close multiple images loaded after obtain the data table using JSL

Thanks a lot @Jeff_Perkinson  & @txnelson . Got it !