MATLAB Answers

double matrix to image conversion

10 views (last 30 days)
BHANU SRINIVASA
BHANU SRINIVASA on 31 Jan 2020
Commented: BHANU SRINIVASA on 1 Feb 2020
i have a double matrix i have to convert it to an image

  0 Comments

Sign in to comment.

Answers (2)

Cris LaPierre
Cris LaPierre on 31 Jan 2020
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 Comment

BHANU SRINIVASA
BHANU SRINIVASA on 1 Feb 2020
i have converted the matrix to uint8 also the image is getting displayed in b/w

Sign in to comment.


Subhadeep Koley
Subhadeep Koley on 1 Feb 2020
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 Comments

Show 5 older comments
BHANU SRINIVASA
BHANU SRINIVASA on 1 Feb 2020
also how to do this scatter plot
Subhadeep Koley
Subhadeep Koley on 1 Feb 2020
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 on 1 Feb 2020
thank u very much i found the defect and got the answer
there was a mistake in the loop

Sign in to comment.

Sign in to answer this question.


Translated by