Image from a 1x1Byte[] .NET Object

1 visualización (últimos 30 días)
Nom
Nom el 14 de Mayo de 2020
Editada: Henry Barth el 16 de Mzo. de 2021
Hello,
So I get a 1x1 Byte[] called imageHandle that is meant to hold a bitmap image (I believe it's meant to be a 448x501x3 uint8 variable). However when I run the following code:
uintVar = uint8(imageHandle);
I get ans = 1x897832 uint8.
Is there some sort of function I should be running in arrange these bits into a viewable image?
I have attached the uintVar.mat file, was not able to attach the imageHandle variable as matlab doesn't load .NET objects from a .mat file.
  6 comentarios
Walter Roberson
Walter Roberson el 14 de Mayo de 2020
There is no such thing as a device-independent bitmap, not really. bitmaps are inherently raster oriented, and that makes them device dependent. .bmp are not device independent either. Device independent is a pain to do.
If you had color information that was device-independent then when properly rendered it would appear as the same color on all displays, even if they used different display technologies such as CRT vs LCD vs LED. If the stored information does not have a gamma map and color temperature information (better yet, spectral illumination information) then it is not device independent.
Anyhow, the .mat file did not get attached :(
Nom
Nom el 14 de Mayo de 2020
Oh crap I am so sorry, I didn't realize I forgot to attach the .mat file entirely!
I attached the uintVar var file which is the 1x897832 uint8.
I also attached the imageHandle.mat which is the system.Byte[] in question, but matlab doesn't let you load it in as a .NET object.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Mayo de 2020
Editada: Walter Roberson el 15 de Mayo de 2020
cols = 501; rows = 448;
RGBA = flipud(permute(reshape(uintVar(41:end),4,cols,rows),[3 2 1]));
imshow(RGBA(:,:,1:3))
  9 comentarios
Nom
Nom el 27 de Mayo de 2020
Thank you, learned a lot about image processing with this problem; all thanks to you.
Henry Barth
Henry Barth el 16 de Mzo. de 2021
Editada: Henry Barth el 16 de Mzo. de 2021
I assume you are reading this image data from an omicron system over the supplied .NET interface. The bytestream contains only the second header of the bitmap format described on wikipedia so you have to subtract these offset values by 14 (13 for matlab). The fourth channel only consists of 255 except for to highest row as well as the left-most column. You can eliminate that using:
bmpArrayCorrected = RGBA(:,:,1:3);
rChannel = RGBA(:,:,1);
gChannel = RGBA(:,:,2);
bChannel = RGBA(:,:,3);
rChannel(1,:) = mode(rChannel,'all');
rChannel(:,1) = mode(rChannel,'all');
gChannel(1,:) = mode(gChannel,'all');
gChannel(:,1) = mode(gChannel,'all');
bChannel(1,:) = mode(bChannel,'all');
bChannel(:,1) = mode(bChannel,'all');
% r and b channels are swapped in omicron data, swap them
bmpArrayCorrected(:,:,3) = rChannel;
bmpArrayCorrected(:,:,2) = gChannel;
bmpArrayCorrected(:,:,1) = bChannel;

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by