3D array of an image to 2D array of the same image
Show older comments
Hi,
How can I transform a 3D array (of an image) to 1 2D array of the same image without loosing the image, of course, but resulting grayscale image is acceptable. For example,
jpegimage = imread('image001','jpeg');
>> size(jpegimage)
ans =
288 384 3
'jpegimage' is a 3D array. I want this array to convert into a 2D array. I did some experiments with MS paint and saw that converting a JPEG image to a GIF does exactly the same.i.e.:
>> imread('image','gif');
>> size(ans)
ans =
288 384
>>
And the resulting image looks exactly similar (grayscale due to imshow function). But I cannot do this with MS paint because I have huge collection of images. Therefore I try following:
>> imwrite(jpegimage,'Image002','gif');
Warning: Image data contains values that are out of range. Out of range values will be given the nearest valid value.
> In imagesci\private\writegif at 339 In imwrite at 406
But what i get as a result is a 3*1 GIF image.
Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!