double matrix to image conversion

回答 (2 件)

Cris LaPierre
Cris LaPierre 2020 年 1 月 31 日

0 投票

How are you trying to view the image?
I suspect you need to use uint8 to first convert your doubles to a value between 0 and 255. See here.

1 件のコメント

BHANU SRINIVASA
BHANU SRINIVASA 2020 年 2 月 1 日
i have converted the matrix to uint8 also the image is getting displayed in b/w

サインインしてコメントする。

Subhadeep Koley
Subhadeep Koley 2020 年 2 月 1 日

0 投票

Hi, try the code below
% Rescale your matrix in 0-255 range
rescaledMatrix = rescale(yourDoubleMatrix, 0, 255);
% Typecasted to uint8
rescaledMatrix = uint8(rescaledMatrix);
% Display your image
figure; imshow(rescaledMatrix, []);
This might help!

8 件のコメント

BHANU SRINIVASA
BHANU SRINIVASA 2020 年 2 月 1 日
d.jpgim getting this kind of image
Subhadeep Koley
Subhadeep Koley 2020 年 2 月 1 日
Can you provide your double matrix as a MAT file? So that I can check the same.
You can generate the MAT file with the following command.
save('yourDoubleMatrix.mat','yourDoubleMatrix');
BHANU SRINIVASA
BHANU SRINIVASA 2020 年 2 月 1 日
these are the 2 outputs
c1 is the matrix after the encryption
and q is the matrix after decryption
i'm able to display the images in b/w but not in the colored form
Subhadeep Koley
Subhadeep Koley 2020 年 2 月 1 日
Yes, it is expected that you will get an image which looks like grayscale because, when I plot a 3D scatter plot on the R, G, and B channel of your matrix "q", it produce a linear trend of the Red-Green-Blue channel, indicating a high correlation among them.
bandCorrRGB.png
This means pixel values in the R, G, and B channels are almost the same.
This is the reason why your image appears grayscale, even if it is a matrix of dimension 187x269x3.
BHANU SRINIVASA
BHANU SRINIVASA 2020 年 2 月 1 日
how can i solve this
BHANU SRINIVASA
BHANU SRINIVASA 2020 年 2 月 1 日
also how to do this scatter plot
Subhadeep Koley
Subhadeep Koley 2020 年 2 月 1 日
The "q" is generated from "c1" by your algorithm only. Therefore it is not possible for me to comment on how this can be solved.
The code for the 3D scatter plot is below.
close all; clear all;
load q.mat;
r = q(:,:,1);
g = q(:,:,2);
b = q(:,:,3);
plot3(r(:),g(:),b(:),'.');
grid on; box on;
xlabel('Red Channel');
ylabel('Green Channel');
zlabel('Blue Channel');
title('Scatterplot of the Visible Bands');
BHANU SRINIVASA
BHANU SRINIVASA 2020 年 2 月 1 日
thank u very much i found the defect and got the answer
there was a mistake in the loop

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

質問済み:

2020 年 1 月 31 日

コメント済み:

2020 年 2 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by