Convert a matrix of doubles to an RGB image, and then back to a matrix of doubles (ideally matching the original)?
Mostra commenti meno recenti
Can someone offer any advice on how one could take a matrix of doubles, convert it to an RGB image, and then BACK to the original matrix of doubles? Here's my stab at it:
Matrix of doubles
mat = 100*peaks(100); minV = min(mat(:)); mat = mat - minV; % Make the min=0 just because.
figure; imagesc(mat)
title('Matrix of Doubles')
colorbar
matMin = min(mat(:)); matMax = max(mat(:));
Double to RGB
matRGB = double2rgb(mat,jet); % This function is on the FEX...
figure; imagesc(matRGB)
colorbar
title('RGB Image')
RGB back to Double, by way of grayscale?
matGray = im2gray(matRGB);
figure; imagesc(matGray)
colorbar
title('Grayscale')
matDoub = rescale(matGray,matMin,matMax); % Rescale the grayscale matrix to recover the original?
figure; imagesc(matDoub)
colorbar
title('Back to Double?')
Test of difference between original matrix and the recovered one.
delta = matDoub - mat;
sum(delta(:)) % Nope!
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Color and Styling in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!