How to fix error:Error using imread>get_full_filename (line 570) File "i,m" does not exist?

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

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));
@Mathieu NOE the result is strange=.09 it seems the function read again the black image (Label_1.png),
if you use imshow(i,m) (I have atached it with name i.png) you will see the labled pixel wich very similar to image 7001-236.png, that mean it should give higher similarity. How to fix it?
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);
@Mathieu NOE I appreciated your help , I am not an image processing expert and coding too, But i want to ask about your technique ,is it same of jaccard index (IoU) method to find similarity because I have a task and I should explain each point? Does this a new method you created?
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.
@Mathieu NOE I have two questions :1- the part of area union you said m*n is the total pixels for two images, but you said in the code:
[m,n] = size(AA);
which is only realated to image AA ,which is the resized of image 7001-236.png, so it relates to only one image not 2 images, you didnt consider in this multiplication Bw_groundTruth. on ontherway which image does m and n refer to?
2-when I used jaccard index I got another result as shown below:
A = logical(imread('7001-236.png'));
BW_groundTruth =logical(i);
similarity = jaccard(squeeze(A(:,:,1)), BW_groundTruth)
similarity =
0.0925
So , how to explain this different?
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)
ind = AA == BW_groundTruth; numel(find(ind))
could be simplified / made more efficient with nnz(ind) instead of numel(find(ind))
tx for the tip ! almost never used that function. have to remember it !
@Mathieu NOE jaccard function worked with only similar size and this is the link show how to apply the jaccard function
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
@Mathieu NOE there is another method to measure similarity like (ssim) ,but the common is jaccrad(IoU) index

Sign in to comment.

Answers (1)

BW_groundTruth =logical(i);
instead of
BW_groundTruth =logical(imread('i,m'));

2 Comments

@Torsten the result is strange=.09 it seems the function read again the black image (Label_1.png),
if you use imshow(i,m) (I have atached it with name i.png) you will see the labled pixel wich very similar to image 7001-236.png, that mean it should give higher similarity. How to fix it?
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.

Sign in to comment.

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Asked:

on 11 Oct 2023

Commented:

on 20 Oct 2023

Community Treasure Hunt

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

Start Hunting!