<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Need help with graphing a binary image matrix in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Need-help-with-graphing-a-binary-image-matrix/m-p/62263#M33553</link>
    <description>&lt;P&gt;Hello, I have an image which is a binary 2D matrix.&lt;BR /&gt;Is there a way I can graph it on JMP? The graph should show a black dot for ones and nothing for zeros.&lt;BR /&gt;Attached is the file that needs to be graphed.&lt;BR /&gt;Thaks for the help!&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jul 2018 16:28:46 GMT</pubDate>
    <dc:creator>SHRG</dc:creator>
    <dc:date>2018-07-06T16:28:46Z</dc:date>
    <item>
      <title>Need help with graphing a binary image matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-with-graphing-a-binary-image-matrix/m-p/62263#M33553</link>
      <description>&lt;P&gt;Hello, I have an image which is a binary 2D matrix.&lt;BR /&gt;Is there a way I can graph it on JMP? The graph should show a black dot for ones and nothing for zeros.&lt;BR /&gt;Attached is the file that needs to be graphed.&lt;BR /&gt;Thaks for the help!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 16:28:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-with-graphing-a-binary-image-matrix/m-p/62263#M33553</guid>
      <dc:creator>SHRG</dc:creator>
      <dc:date>2018-07-06T16:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with graphing a binary image matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-with-graphing-a-binary-image-matrix/m-p/62272#M33559</link>
      <description>&lt;P&gt;Here are a couple of ways to do this.&amp;nbsp; The first one is a cell plot.&amp;nbsp; To do this, one needs to correct your data table.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Delete row 1.&lt;/P&gt;
&lt;P&gt;2. Select all columns&lt;/P&gt;
&lt;P&gt;3. Using Standardize Attributes, change all columns from a Data Type of Character to a Data Type of Numeric.&lt;/P&gt;
&lt;P&gt;4. Using Standardize Attributes, create a Column Property of Value Colors, and set the color of the value 0 to white, and the color of the value 1 to black&lt;/P&gt;
&lt;P&gt;5. Run the Cell Plot Platform&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Graph==&amp;gt;Cell Plot&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; Select all of the column and place them into the Y Response, and click on OK&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dots1.PNG" style="width: 410px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/11402i37CAB615D2A27A95/image-size/large?v=v2&amp;amp;px=999" role="button" title="dots1.PNG" alt="dots1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The second example is to use the Graph Builder&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Taking the above modified data table, a new column representing the row the data is in needs to be added. So, add a column called "Row" and set it's formula to&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Row()&lt;/P&gt;
&lt;P&gt;2. The data now needs to be stacked into basically one column of the zeros and ones.&amp;nbsp; Using the&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Tables==&amp;gt;Stack&lt;/P&gt;
&lt;P&gt;platform, copy all of the columns, "Column 2" thru "Column 26" into the Stack Columns.&lt;/P&gt;
&lt;P&gt;3. In the "Non-stacked columns" section, select the "Select" checkbox, and the choose the "Row" column.&lt;/P&gt;
&lt;P&gt;3. Click on OK&lt;/P&gt;
&lt;P&gt;4. In the new stacked data table, create a new column called "Column" and set the formula to&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Num(Word(-1,:Label," "))&lt;/P&gt;
&lt;P&gt;This will take the column number from the Label column, and make it a numeric value in the new colum&lt;/P&gt;
&lt;P&gt;5. Open the Graph Builder Platform&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Graph==&amp;gt;Graph Builder&lt;/P&gt;
&lt;P&gt;6. Drag the Row column to the Y drop area&lt;/P&gt;
&lt;P&gt;7. Drag the Column column to the X drop area&lt;/P&gt;
&lt;P&gt;8. Right click on the graph and select&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Smoother==&amp;gt;Remove&lt;/P&gt;
&lt;P&gt;9. Drag the Data column to the Color drop area&lt;/P&gt;
&lt;P&gt;10. Right click on the colored dot for the 0 in the legend and select&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Color==&amp;gt;White&lt;/P&gt;
&lt;P&gt;11. Right click on the colored dot for the 1 in the segend and select&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Color==&amp;gt;Black&lt;/P&gt;
&lt;P&gt;You will get this chart&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dots2.PNG" style="width: 944px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/11403i32801C6D248B2452/image-size/large?v=v2&amp;amp;px=999" role="button" title="dots2.PNG" alt="dots2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Other methods are available too.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 17:41:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-with-graphing-a-binary-image-matrix/m-p/62272#M33559</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-07-06T17:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with graphing a binary image matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-with-graphing-a-binary-image-matrix/m-p/62273#M33560</link>
      <description>Thank you very much!</description>
      <pubDate>Fri, 06 Jul 2018 18:00:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-with-graphing-a-binary-image-matrix/m-p/62273#M33560</guid>
      <dc:creator>SHRG</dc:creator>
      <dc:date>2018-07-06T18:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with graphing a binary image matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-with-graphing-a-binary-image-matrix/m-p/62279#M33565</link>
      <description>&lt;P&gt;Here is another way to do this, with JSL and creating an image file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// data preparation, the data table needs some work to get it ready 
_dt = Current Data Table();
_dt &amp;lt;&amp;lt; Select rows( 1 );
_dt &amp;lt;&amp;lt; delete rows;

For( ii = 1, ii &amp;lt;= N Cols( _dt ), ii++,
	Column( _dt, ii ) &amp;lt;&amp;lt; Set Name( "phase_" || Char( ii - 1 ) );
	Column( _dt, ii ) &amp;lt;&amp;lt; Set Data Type( Numeric );
	Column( _dt, ii ) &amp;lt;&amp;lt; Set Modeling Type( Continuous );
);
		


// Make an image file and display in new window with scaling control

// this assumes the entire table just has the binary columns
// get the binary values as a matrix
m = _dt &amp;lt;&amp;lt; get as matrix;

//  get the dimensions of the table/matrix
mdim = Dim( m );

// specify a minimum image size in pixels, this prevents the image from being
// too small to be useful
mininumimagepixeldim = [800 800];
// determine a scale factor to bring the size of the matrix up to the minimum dimensions
// specified above
scale_x = Ceiling( mininumimagepixeldim[2] / mdim[2] );
scale_y = Ceiling( mininumimagepixeldim[1] / mdim[1] );
// create a scaled image matrix, using the scale factors determined above
// and applying the direct product to scale up the image
r = 1 - Direct Product( m, J( scale_y, scale_x, 1 ) );

// create an image from the scaled image matrix
img = New Image( "rgb", {r, r, r} );
scalefactor = 1;

// create the display window
_nw = New Window( "Binary Image",
	Outline Box( "Binary Image", 
		// create a slider controller to rescale the image
		// this works by recreated the image, applying the scale factor,
		// deleting the image in the display and redrawing the new image
		V List Box(
			H List Box(
				Text Box( "Move Slider to Scale Image " ),
				Slider Box(
					.5,
					1,
					scalefactor,
					img = New Image( "rgb", {r, r, r} );
					img &amp;lt;&amp;lt; Scale( scalefactor );
					_picb &amp;lt;&amp;lt; delete;
					_panelb &amp;lt;&amp;lt; Append( _picb = Picture Box( img ) ) 
			           	
					;
				)
			), 
			// draw the binary image inside a panel box (just to give it an outline and a container)
			_panelb = Panel Box( "Binary Image", _picb = Picture Box( img ) )
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The result looks like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2018-07-06_15-09-14.png" style="width: 683px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/11404iEB6E20ADD538CD09/image-size/large?v=v2&amp;amp;px=999" role="button" title="2018-07-06_15-09-14.png" alt="2018-07-06_15-09-14.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 19:12:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-with-graphing-a-binary-image-matrix/m-p/62279#M33565</guid>
      <dc:creator>MathStatChem</dc:creator>
      <dc:date>2018-07-06T19:12:43Z</dc:date>
    </item>
  </channel>
</rss>

