Problem with imresize function.
Mostra commenti meno recenti
The problem i am facing is that imresize is not a reversible function.For example,if you convert a binary array of size 5x8 to an array of size 1x192 and then convert it back to size of 5x8,the values are not the same.In case,if u use 'bilinear' attribute then it gives back binary values,however,the values don't match.Please guide me how i can overcome the above problem.(Note:its not essential that the above problem be solved using imresize function.)Any help would be appreciated.
Risposta accettata
Più risposte (2)
Jan
il 23 Apr 2012
Resizing an image until it has a single row only cannot be reversible. Reshaping seems to be more useful, if the problem is not restricted to imresize:
x = rand(5, 8);
y = zeros(1, 192);
y(1:numel(x)) = x(:)';
And backwards:
x2 = reshape(y(1:(5 * 8)), 5, 8);
2 Commenti
Anish Surana
il 23 Apr 2012
Jan
il 23 Apr 2012
Then, of course, you can omit the zeros and use this:
y = x(:).'
Geoff
il 23 Apr 2012
The upscale and subsequent downscale of 8 > 192 > 8 should be fine, but I don't know how you expect resizing from 5 > 1 > 5 is going to give you back the same information. When you collapse 5 lines down to 1, you lose all the information in those lines. You cannot scale it back up to 5 and expect your original data to come back out.
Think of this:
R = rand(5,1);
M = mean(R);
How do you recover R using only M?
1 Commento
Anish Surana
il 23 Apr 2012
Categorie
Scopri di più su Language Fundamentals in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!