white images when using h5read, is it normal ?
3 views (last 30 days)
Show older comments
Hello,
I have created a hdf5 files with 2 datasets of images to put them as an input in a convolutional neural network.
Before being written in the .h5 files my images are normal but after I created my .h5 file and try to read the data the images are all white.
Here is my code :
h5create('uNetDataSet.h5','/image',size_data_train);
h5create('uNetDataSet.h5','/anno',size_data_train_anno);
h5write('uNetDataSet.h5','/image',Data_train);
h5write('uNetDataSet.h5','/anno',Data_train_anno);
h5disp('uNetDataSet.h5')
Image = h5read('uNetDataSet.h5','/image');
imshow(Image(:,:,:,3));
Is it normal ? What exactly does the function h5write ? If it is not normal, does anyone have a idea how to solve this ?
(I am using Matlab R2015a on Ubuntu 14.04)
0 Comments
Answers (2)
Image Analyst
on 25 Jul 2016
It's possibly a floating point image, so use [] in imshow to automatically scale your image. The problem without doing that is then imshow() will assume your floating point variable is in the range 0-1. If it's not, like it's in the range 0-255 or 0-65535 or some other range, then anything greater than 1 will show up as white.
imshow(Image(:,:,:,3), []);
I'd also recommend not using Image as the name of a variable since there is a built in function called image(). Granted, MATLAB is case sensitive, but it's still preferred to not use the same name even if there is a capitalization difference. Call it myImage or something.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!