how do I make this image whietish?
2 views (last 30 days)
Show older comments
How do I make this first image like this second image?![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/832465/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/832465/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/832470/image.png)
Accepted Answer
More Answers (1)
DGM
on 13 Nov 2022
Edited: DGM
on 13 Nov 2022
To recreate this image in this specific example, we might compare it directly to its source and see what's been changed. Unfortunately, the result is a screenshot, so it's not the right size and it has then been subsequently cropped so that some edges are missing and others have padding. Stop saving images by saving the figure. It's only slightly less ridiculous than taking a tilted portrait photograph of the monitor with a cell phone.
So let's say we went out of our way to try to resize/crop/fill the image back into rough correspondence with the original. Then we could compare the two. I'm going to assume that whatever transformation was applied was applied equally to all channels.
A = imread('peppers.png'); % the original
B = imread('cccc.png'); % the garbage image
% try to figure out what each input value maps to
av0 = im2double(A(:));
bv0 = im2double(B(:));
[av idx] = unique(av0);
bv = zeros(size(av));
for k = 1:numel(av)
idx = av0 == av(k);
thesepix = bv0(idx);
bv(k) = median(thesepix);
end
plot(av,bv)
xlim([0 1])
ylim([0 1])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1191498/image.png)
Why am I binning and finding the median for all the pixels instead of just comparing each one? That's because two pixels with the same value in A won't necessarily map to the same value in B -- because B is a significantly degraded copy of what used to be the actual output. B has been subject to interpolation when displayed, and again when saved. Whenever the saved image was then opened and edited manually, any number of other things might have happened. Yet more interpolation happens when B was rescaled to register it with A. Everything is blurred and slightly misaligned. If we had just tried to compare the pixel values directly, this is all we'd see:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1191518/image.png)
If we can get a clear plot, we try to see if there's an obvious indication of what the initial value transformation was. Given the roughly piecewise-linear plot, it looks like a basic levels adjustment. Maybe there's a bit of gamma; maybe that's just reading tea leaves.
C = imadjust(A,[0 0.2],[0.2 1],1.2); % recreate the requested image
montage({B,C})
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1191843/image.png)
That looks about right.
See also:
0 Comments
See Also
Categories
Find more on Convert Image Type 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!