Saving a Matrix as an Image and then extracting same matrix from Image.

조회 수: 5(최근 30일)
There is a "smag" value that has the type double. I want to save the "smag" matrix in the form of image and send the image to some person. I want the other person to read the image and extract the "smag" value. Now, when I read the image I get a matrix of type uint8. Attaching the smag mat file as a reference.
All I want is to save the smag as a figure and then read the figure to extract the same matrix ("smag") of something similar or near similar.
smag.mat file is attached for the reference. Any help would be appreciated.
clear all
close all
load('smag.mat') %smag is of type double
b=imread('FigureNew.jpeg'); %The b matrix comes out to be of type uint8
%I want to extract the smag value from the matrix b.

채택된 답변

madhan ravi
madhan ravi 2021년 5월 30일
SMAG = im2double(b) %
IM2DOUBLE Convert image to double precision. IM2DOUBLE takes an image as input, and returns an image of class double. If the input image is of class double, the output image is identical to it. If the input image is not double, IM2DOUBLE returns the equivalent image of class double, rescaling or offsetting the data as necessary. I2 = IM2DOUBLE(I1) converts the intensity image I1 to double precision, rescaling the data if necessary. RGB2 = IM2DOUBLE(RGB1) converts the truecolor image RGB1 to double precision, rescaling the data if necessary. I = IM2DOUBLE(BW) converts the binary image BW to a double- precision intensity image. X2 = IM2DOUBLE(X1,'indexed') converts the indexed image X1 to double precision, offsetting the data if necessary. Class Support ------------- Intensity and truecolor images can be uint8, uint16, double, logical, single, or int16. Indexed images can be uint8, uint16, double or logical. Binary input images must be logical. The output image is double. Example ------- I1 = reshape(uint8(linspace(1,255,25)),[5 5]) I2 = im2double(I1) See also DOUBLE. Documentation for im2double doc im2double Other functions named im2double codistributed/im2double gpuArray/im2double tall/im2double
  댓글 수: 1
Fareed Jamali
Fareed Jamali 2021년 5월 30일
편집: Fareed Jamali 2021년 5월 30일
Your approach works but the only problem is that there is too much noise as a result. I have attached the smag.mat file in the post. What I am trying to implement is in the link. Thank you for your answer. The part I am coding right now looks like;
clear all
close all
[x,tx,info] = stftmag2sig(smag2,nfft,Fs,'Window',wind,'OverlapLength',olen); % Works on matlab version R2021a

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

추가 답변(0개)


Find more on Image Processing and Computer Vision in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by