cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
LR237787
Level I

JSL- get values of pixels in 0-255

Hi all, I am trying to get pixel values in 0-255 using Get Pixels().

 

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

This gives me normalized values (0-1). How can I get the pixel values in 0-255?

 

Thanks!

2 REPLIES 2
jthi
Super User

Re: JSL- get values of pixels in 0-255

Just guessing here, but maybe it would be enough to just multiply by 255?

 

This link could also give ideas (and has additional links) What do the numbers returned by << Get Pixels(); correspond to? 

-Jarmo
ian_jmp
Level X

Re: JSL- get values of pixels in 0-255

I think there's more than one way to do this. But here's a reference and a JMP implementation:

Names Default To Here( 1 );

Web("https://web.stanford.edu/class/cs101/image-6-grayscale.html", JMP Window);

img = Open( "$SAMPLE_IMAGES/tile.jpg", jpg );
win = New Window( "tile(40,40)", img );
{r, g, b} = img << Get Pixels( "rgb" );

// Average the rgb values of each pixel and scale from [0, 1] to [0, 255]
nr = NRow(r);
nc = NCol(r);
r2 = Shape(r, 1, nr*nc);
g2 = Shape(g, 1, nr*nc);
b2 = Shape(b, 1, nr*nc);
g2 = VMean(VConcat(r2, g2, b2));
g = Shape(g2, nr, nc);
g = Round(g*255, 0);
dt = AsTable(g);
dt << setName("Greyscale");

Recommended Articles