Is it possible to reconstruct an image from the number of pixel counts and bins information?

2 views (last 30 days)
Gobert on 20 Jan 2022
Commented: Gobert on 21 Jan 2022
Happy New Year and I need your help!
I have the following imhist function that yields the number of pixel counts and bin locations.
[counts,binLocations] = imhist(I)
Is it possible to reconstruct a "new" image using the number of "new pixel" counts and "same" bins information? If yes - can you please suggest how?

Accepted Answer

Walter Roberson
Walter Roberson on 20 Jan 2022
I = imread('pout.tif');
I1 = reshape(sort(I), size(I));
[c,b] = imhist(I);
[c1,b1] = imhist(I1);
all(c == c1)
ans = logical
all(b == b1)
ans = logical
Two different images, exactly the same counts and bin values.
It follows that knowing the counts and bin locations is not enough to recreate the image.

More Answers (1)

Matt J
Matt J on 20 Jan 2022
Edited: Matt J on 20 Jan 2022
As Walter has shown, it is not an invertible mapping, however, if you use histcounts() instead, there is enough information for a coarse inversion:
I = double(imread('pout.tif'));
Irecon=reshape(vals(label), size(I)); %reconstructed
  1 Comment
Gobert on 21 Jan 2022
Thanks, Matt J. I would also love to accept your answer - but I did not see the option to accept two constructive answers on this platform.

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!

Translated by