how do I make this image whietish?
조회 수: 1(최근 30일)
DGM 2022년 11월 13일
편집: DGM 2022년 11월 13일
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);
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:
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
That looks about right.