Java Byte array to uint8 array
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jason Klebes
el 1 de Mzo. de 2023
Comentada: Jason Klebes
el 3 de Mzo. de 2023
I call java functions which return what is supposed to be a uint8 image with values from 0 to 255.
import java.ij.*;
I = ij.ImagePlus('filepath'); %read an 8bit image from file to java.ij.ImagePlus object
Idata= Ip.getImageStack().getImageArray(); %getImageArray() an array of Java Byte s
Idata % a matlab array of int8 values
In Java, it's a ByteArray with 8-bit entries. On returning the data to matlab, the Byte type gets automatically converted to int8, not uint8.
https://uk.mathworks.com/help/mps/java/conversion-of-java-types-to-matlab-types.html
The numbers are in range -127 to 128, not 0 to 255.
How can I force the Java Byte to be interpreted as uint8, OR convert matlab int8 to uint8 afterwards?
0 comentarios
Respuesta aceptada
Jan
el 1 de Mzo. de 2023
siz = size(Idata);
Idata = reshape(typecast(Idata(:), 'uint8'), siz);
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Call Java from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!