Image from a 1x1Byte[] .NET Object

조회 수: 1 (최근 30일)
Nom
Nom 2020년 5월 14일
편집: Henry Barth 2021년 3월 16일
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
Walter Roberson
Walter Roberson 2020년 5월 14일
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 2020년 5월 14일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 5월 15일
편집: Walter Roberson 2020년 5월 15일
cols = 501; rows = 448;
RGBA = flipud(permute(reshape(uintVar(41:end),4,cols,rows),[3 2 1]));
imshow(RGBA(:,:,1:3))
  댓글 수: 9
Nom
Nom 2020년 5월 27일
Thank you, learned a lot about image processing with this problem; all thanks to you.
Henry Barth
Henry Barth 2021년 3월 16일
편집: Henry Barth 2021년 3월 16일
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;

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Getting Started with Microsoft .NET에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by