MATLAB Answers

How to read images with positive integer? No imead()

2 views (last 30 days)
Wenyi Xiao
Wenyi Xiao on 26 Apr 2019
Edited: madhan ravi on 26 Apr 2019
I want to import images into matlab workspace, they should contain positive integers and zeros. If I use imread(), they will be all zeros.


Image Analyst
Image Analyst on 26 Apr 2019
Why? What kind of integers are they? I doubt they will be all zeros with imread(). Please attach your image.
Geoff Hayes
Geoff Hayes on 26 Apr 2019
Wenyi - can you attach one of these images so that we can take a look at it? Or describe the images - what type are they? What is the integer type (8-bit, 16-bit, etc.)?

Sign in to comment.

Accepted Answer

Catalytic on 26 Apr 2019
Edited: Catalytic on 26 Apr 2019
I definitely don't get all zeros with imread. Problem solved?
>> nnz(imread('C0039_100122_INDS.png'))
ans =
>> nnz(imread('C0039_101785_INDS.png'))
ans =


Wenyi Xiao
Wenyi Xiao on 26 Apr 2019
WeChat Screenshot_20190426114417.png
I store image data like this.
Each matrix contains data of one of the images.
However, when I look the data, they are all zeros.
Wenyi Xiao
Wenyi Xiao on 26 Apr 2019
images_data = cell(1500,1);
for S = 1:size(want_files,1)
images_data{S,1} = imread(pngFile_names{want_files(S,1),1}); %load image data from 1500 matched files
this is the code I used.
Wenyi Xiao
Wenyi Xiao on 26 Apr 2019
I found the positive integers, Thank you!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!