How to fix error:Error using imread>get_full_filename (line 570) File "i,m" does not exist?
Show older comments
I used pixel label from image labeler App.There is a menu 'Export Labels > To File' in the Image Labeler App and it generates a new folder called <PixelLabelData> containing PNG label files. Then I opened the file which created called PixelLabeData and I found the labeled image is totally black(label_1.png) I apllied the followig code to display it :
figure;
[i, m] = imread('Label_1.png');
imshow(i,m)
Then, I applied jaccrad index:
A = logical(imread('7001-236.png'));
BW_groundTruth =logical(imread('i,m'));
similarity = jaccard(squeeze(A(:,:,1)), BW_groundTruth)
I got the following error:
Error using imread>get_full_filename (line 570)
File "i,m" does not exist.
Error in imread (line 377)
fullname = get_full_filename(filename);
Error in Untitled_ask (line 8)
BW_groundTruth =logical(imread('i,m'));
12 Comments
Mathieu NOE
on 11 Oct 2023
this is wrong :
BW_groundTruth =logical(imread('i,m'));
there is no image file with name i,m
you probably wanted to do instead
BW_groundTruth =logical(i));
yasmin ismail
on 11 Oct 2023
Mathieu NOE
on 11 Oct 2023
Edited: Mathieu NOE
on 11 Oct 2023
ok, have to say I am not an image processing expert, I simply found your code looked strange to me
as also I don't have the image processing Tbx, I had to find a way to compute a similarity, simply by checking the matching 0 or 1 logical indexes found in both images
according to my method , I have a similarity of 0.967825451508508
[i, ~] = imread('Label_1.png');
A = imread('7001-236.png');
AA= logical(squeeze(A(:,:,1)));
BW_groundTruth =logical(i);
% my pseudo code for similarity
[m,n] = size(AA);
ind = AA == BW_groundTruth; % matching logical indexes 0 or 1 in both images
similarity = numel(find(ind))./(m*n);
yasmin ismail
on 11 Oct 2023
Mathieu NOE
on 11 Oct 2023
Edited: Mathieu NOE
on 11 Oct 2023
maybe I was lucky this time (first time today) .... because one hour before I didn't know anything about Jaccard similarity index

according to the above picture the IoU is the ratio of the area of overlap divided by the area of union
the ratio I have computed is what I have assumed to be a good alternative (or even the right one ?)
- my "area of overlap" is the number of logical 0 or 1's that are common to both images (at the same row/column positions) : ind = AA == BW_groundTruth; numel(find(ind))
- my "area of union" is simply the total number of pixels in both images (they are of equal sizes) : (m*n)
maybe a true image expert will tell how good or bad is my approximation of IoU
now there is no reason why you cannot use the jaccard function you have access to.
yasmin ismail
on 11 Oct 2023
Mathieu NOE
on 12 Oct 2023
Edited: Mathieu NOE
on 12 Oct 2023
hello again
1/ when I read your posted images I got the same size (309 x 310)

I haven't made any resize operation
so m and n are the rows and columns of your images (and are identical for both of them) , and the number of pixels is simply the product m*n of course
2/ cannot answer this as I cannot run your code as I don't have access to the jaccard function. But I recognize that such a low similarity value seems indeed strange but maybe it's simply because I have not yet understood the jaccard concept ! I need more time
3/ my approach was rather simple , maybe pictures would explain better than a long text :
here from left to right the 3 plots of some of our data :
>> figure(1),imagesc(AA)
>> figure(2),imagesc(BW_groundTruth)
>> figure(3),imagesc(ind)

what we see on the right (fig 3) in yellow (value = 1 logical) is pixels of the two images that are either both black or both white
the only logical zeros (blue) on this 3rd figure are pixels that are black in one image and white in the other
my similarity index (if we can use that definition) is simply the ratio of how many common pixels are indentified vs the total (same) number of pixels in both images. Anyway, you can do my computation only if both images have exact same size. i haven't checked if the jaccard function works on dissimilar size of images (have to look at the doc)
Walter Roberson
on 12 Oct 2023
ind = AA == BW_groundTruth; numel(find(ind))
could be simplified / made more efficient with nnz(ind) instead of numel(find(ind))
Mathieu NOE
on 12 Oct 2023
tx for the tip ! almost never used that function. have to remember it !
yasmin ismail
on 12 Oct 2023
Mathieu NOE
on 20 Oct 2023
tx but I don't have the Image Processing Tbx , so I probably will never use the native jaccard function . is there a Fex alternative ? I haven't seen one for the time being
yasmin ismail
on 20 Oct 2023
Answers (1)
BW_groundTruth =logical(i);
instead of
BW_groundTruth =logical(imread('i,m'));
2 Comments
yasmin ismail
on 11 Oct 2023
Walter Roberson
on 11 Oct 2023
imshow(i,m) is a request to display the content of the variable i using m as a scaling range if m is a vector of length 2, or using m as a colormap. Unless, that is, i is a character vector or string scalar in which case i holds the name of a file to read and display.
Categories
Find more on Image Processing and Computer Vision 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!