Image from a 1x1Byte[] .NET Object

2 ビュー (過去 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 Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by