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!
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?
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");