How to fix error: Error using logical Conversion to logical from table is not possible?

I I used pixel label from image labeler App.There is a menu 'Export Labels > To workSpace' in the Image Labeler App and it exports a table format called gTruth as shown in attached , I got an error when I used it in similarity evaluation as following
A = logical(imread('7001-236.png'));
BW_groundTruth =logical(gTruth);
similarity = jaccard(squeeze(A(:,:,1)), BW_groundTruth)
Error using logical
Conversion to logical from table is not possible.
Error in Untitled_ask (line 5)
BW_groundTruth =logical(gTruth)
how to fix it?

2 Comments

The error clearly states what the problem is.
load('matlab.mat')
gTruth
gTruth = 3×2 table
imageFilename crack _______________________________________________________________________________________________________________________ __________ {'D:\Matlab pics\matlab practices21\Phd analysis\trial meyhods\GroundTruth\Deck GT\work\PixelLabelData_1\7001-236.png'} {0×1 cell} {'D:\Matlab pics\matlab practices21\Phd analysis\trial meyhods\GroundTruth\Deck GT\7001-236.png' } {0×1 cell} {'D:\Matlab pics\matlab practices21\Phd analysis\trial meyhods\GroundTruth\Deck GT\Cracked\7001-236.jpg' } {4×1 cell}
How are you going to take logical values of text?
@Dyuman Joshi I am biggener in matlab and coding, so how i can use it , i want to compaire between labeled image which is in PixelLabelData, with attached image 7001_236.png. so how to fix it?

Sign in to comment.

 Accepted Answer

Well, all you've shown us is a file name in a folder that contains that text string; one presumes you would then have to also load that image as the comparison one?
ix=contains(gTruth.imageFilename,'PixelLabelData'); % look up which is the desired file
BW_groundTruth=logical(imread(gTruth.imageFilename(ix))); % read that image file...

6 Comments

@dpb I still have an error:
load('matlab.mat')
gTruth
ix=contains(gTruth.imageFilename,'PixelLabelData'); % look up which is the desired file
A = logical(imread('7001-236.png'));
BW_groundTruth=logical(imread(gTruth.imageFilename(ix))); % read that image file...
similarity = jaccard(squeeze(A(:,:,1)), BW_groundTruth)
{'D:\Matlab pics\matlab practices21\Phd analysis\trial meyhods\GroundTruth\Deck GT\work\PixelLabelData_1\7001-236.png'} {0×1 cell}
{'D:\Matlab pics\matlab practices21\Phd analysis\trial meyhods\GroundTruth\Deck GT\7001-236.png' } {0×1 cell}
{'D:\Matlab pics\matlab practices21\Phd analysis\trial meyhods\GroundTruth\Deck GT\Cracked\7001-236.jpg' } {4×1 cell}
Error using imread>parse_inputs (line 504)
The file name or URL argument must be a character vector or string scalar.
Error in imread (line 342)
[source, fmt_s, extraArgs, was_cached_fmt_used] = parse_inputs(cached_fmt, varargin{:});
Error in Untitled_ask (line 23)
BW_groundTruth=logical(imread(gTruth.imageFilename(ix))); % read that image file...
how to fix it?
Dereference the cell array in the table..."Use the curlies, Luke!"
ix=contains(gTruth.imageFilename,'PixelLabelData'); % look up which is the desired file
BW_groundTruth=logical(imread(gTruth.imageFilename{ix})); % read that image file...
@dpb thanks for your help ,but I want to clarify for me something to make sure the result of similarity is correct, what i undesrstood from:
load('matlab.mat')
{'D:\Matlab pics\matlab practices21\Phd analysis\trial meyhods\GroundTruth\Deck GT\work\PixelLabelData_1\7001-236.png'} {0×1 cell}
{'D:\Matlab pics\matlab practices21\Phd analysis\trial meyhods\GroundTruth\Deck GT\7001-236.png' } {0×1 cell}
{'D:\Matlab pics\matlab practices21\Phd analysis\trial meyhods\GroundTruth\Deck GT\Cracked\7001-236.jpg' } {4×1 cell}
it shows the three images inside it, how can I know that I choose the corect image?is there away to display each of them?
note: image labeler App export the png labeled image in PixelLabeldata folder
Only you know which image is the right one...we have no way to know what any of them are.
You can open each in turn same way as opened any one...use the filename argument to any one of the image-opening/displaying functions.
@dpb I am new biggener in image processing and matlab. I know the function imshow() to display any image but in this condition how I will dispay each of them? can you show me please
Just loop thru the array of filenames with a for loop using the index of the loop...
for i=1:height(gTruth)
figure
imshow(gTruth.imageFilename{i})
end
"Salt to suit..."

Sign in to comment.

More Answers (0)

Categories

Asked:

on 11 Oct 2023

Commented:

dpb
on 12 Oct 2023

Community Treasure Hunt

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

Start Hunting!