How to denormalize an image to 0-255??

i m using gray lena image as an input,after normalization the [512*512] got changed to [64*255025] in the range of 0-1,how can i get back the original image back???? here the code:
clc
clear all
close all
I=double(imread('C:\Users\data\lena.tif'))/255;
X=im2col(I,[8 8],'sliding');
X=(X-repmat(mean(X),[size(X,1) 1]));
X=X ./ repmat(sqrt(sum(X.^2)),[size(X,1) 1]);

Answers (2)

You cannot get the original image size back. You used sliding windows, so your X is larger than the original image. See the documentation http://www.mathworks.com/help/images/ref/im2col.html:
'sliding' Converts each sliding m-by-n block of A into a column of B, with no zero padding. B has m*n rows and contains as many columns as there are m-by-n neighborhoods of A. If the size of A is [mm nn], then the size of B is (m*n)-by-((mm-m+1)*(nn-n+1)).
If you want to be able to visualize your transformations, use distinct blocks (and you might as well use blockproc()). Or use blockproc() with overlaps and let it throw away everything except one pixel per block -- though I'm not sure how that would work if the block sizes are even numbers rather than odd numbers.

2 Comments

@WALTER roberson i cant get the original image eventhough i convert the obtained large matrix into 512*512 matrix..
How did you convert the large image into a 512 x 512 matrix after the normalization routine you showed?

Sign in to comment.

You can do that whole algorithm in one call (one line of code) to conv2() or imfilter(). Try it.

Asked:

on 1 Sep 2015

Answered:

on 14 Sep 2015

Community Treasure Hunt

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

Start Hunting!