Write a MATLAB function capable of reducing the number of gr
Write a MATLAB function capable of reducing the number of grey levels in an image. The desired number of grey levels needs to be a variable input to your program and must be an integer power of 2 (and less than 256). Write a \"driver\" program to read in the image \"Megeve_512 times 512_256.jpg\", and show the effect on this image of reducing the number of grey levels from 256 to 128. 64. 32. 16. 8. 4 and 2. Zooming and Shrinking Images by Pixel Replication Write a MATLAB function capable of zooming and shrinking an image just by pixel replication. Assume that the desired zoom/shrink factors are integers. You may ignore aliasing effects. You will need to read in \"Megeve_512 times 512_256.jpg\". Use your program to shrink the image \"Megeve_512 times 512_256.jpg\" in (a) from 512 times 512 to 128 \' 128 pixels. Use your program to zoom the image in (b) back to 512 \' 512. Explain the reasons for the differences between the original image and the image that has been shrunk and then expanded back to the original size.
Solution
1a) To achieve this using imshow(Y,colormap(gray(32))); where 32 is the grey level here . but result here using this is not saved . for saved result changes use imquantize(A,levels) quantizes image A using specified quantization values contained in the N element vector levels.
1b)
X = imread(\'Megeve_512x512_256.jpg\');
thresh = multithresh(X,2) //Calculating two threshold levels.
seg_I = imquantize(I,thresh);
2a) use imresize(A,scale) for zooming and skrinking that is scale times the size of A.
2b)
A=imread\'Megeve_512x512_256.jpg\');
