Saving a grayscale image with scaled values
Show older comments
Hello, here is my problem:
I have a 196*196 image, and such matrix looks like that for example:

using imshow("img",[]) displays the image correctly because it's scaled, while not using it produces something like that:

I want to save the correct output that should looke like this:

But I can't find the correct parameters for imwrite...
Also I have to say that Im running it with a loop, and planning later on to do image processing, with batch processor and registration and etc.
6 Comments
KALYAN ACHARJYA
on 8 Nov 2022
Pls attach the image/data, so that we can try on it.
"while not using it produces something like that:" - Please avoid to explain, what you do not do, but mention, what you do to get this image.
Did you try to scale the data by your own?
img = rand(1, 10)
tmp = min(img(:));
img = (img - tmp) / (max(img(:)) - tmp)
Zinoviy
on 8 Nov 2022
Jan
on 8 Nov 2022
folder = "directory"
for i = 1:100
% Scale the image:
img = fisp1(:,:,1,i);
tmp = min(img(:));
img = (img - tmp) / (max(img(:)) - tmp);
% Save the file:
name = fullfile(folder, sprintf('rep%d.png', i));
imwrite(img, name);
end
Zinoviy
on 8 Nov 2022
Accepted Answer
More Answers (0)
Categories
Find more on Introduction to Installation and Licensing 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!