Warning: IMSHOW(I,N) is an obsolete syntax. Your grayscale image will be displayed using 256 shades of gray.

I am getting this warning: Warning: IMSHOW(I,N) is an obsolete syntax. Your grayscale image will be displayed using 256 shades of gray. this code is for basis 2d dct.please help me
m=input('enter the basis matrix dimension:');
n=m;
alpha2=ones(1,n)*sqrt(2/n);
alpha2(1)=sqrt(1/n);
alpha1=ones(1,m)*sqrt(2/m);
alpha1(1)=sqrt(1/m);
for u=0:m-1
for v=0:n-1
for x=0:m-1
for y=0:n-1
a(u+1,v+1,x+1,y+1)=alpha1(u+1)*alpha2(v+1)*cos((2*x+1)*u*pi/(2*n))*cos((2*y+1)*v*pi/(2*n));
end
end
end
end
mag=a;
figure;
colormap('gray');
k=1;
%code to plot basis
for i=1:m
for j=1:n
subplot(m,n,k)
imshow(mag(i,j),256);
k=k+1;
end
end

Answers (1)

Replace
colormap('gray');
with
colormap(gray(256));
Replace
imshow(mag(i,j), 256)
With
imshow(mag(i,j));

5 Comments

I have no idea why you want to display each individual pixel in its own subplot, but you didn't ask about that. Ours is not to reason why...
@Walter Roberson why this code is not working for 64x64 block
Because having 64 by 64 array of plots where you're just displaying one single pixel in each subplot is a dumb thing to do. Now, "mag" and "a" are both 4 dimensional arrays so mag(i,j) is (after checking with a simple example) actually taking mag(i,j,1,1). You should actually use all 4 indexes since it's a 4D array so people don't get confused. But what good does it do to do that rather than get rid of the whole double for loop and do this:
imshow(mag(:,:,1,1), []);
to display all 64 by 64 in just one axes?
@Image Analyst actually i m working sparse approximation where i require to create a overcomplete dct dictionary where no.of columns must be greater than no. of rows ,first using the above code i will create a dct dictionary and the convert it to 64x4096 size dictionary.
You don't need to imshow to create the dictionary. You might want imshow to debug the creation but in that situation putting one pixel per subplot is not going to be useful.
Maybe you want
imshow(squeeze(mag(i, j, :, :)))

Sign in to comment.

Asked:

on 12 Jun 2015

Commented:

on 12 Jun 2015

Community Treasure Hunt

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

Start Hunting!