my labeled image is not overlaying with the original image.
2 views (last 30 days)
Show older comments
i am working on image processing using sematic segmentation. this is the code i have developed so far,
%Import the required network
resnet18();
%Initialize the outputFolder and the supporting folders anf files
outputFolder = fullfile('E:\ICE Research\MATLAB CODES');
%create imageDatastore by specifying the location of the folders and
%sub-folders
imgDir = fullfile(outputFolder, 'images');
imds = imageDatastore(imgDir, "FileExtensions",[".jpg"]);
I = read(imds);
I = histeq(I);
I = imshow(I);
%create pixelLabelDatastore with possible classNames
pixDir = fullfile(outputFolder, 'PixelLabelData');
classNames = ["hemorrhage" "edema" "optic_disk"];
pixelLabelID = [1 2 3];
pxds = pixelLabelDatastore(pixDir, classNames, pixelLabelID, "FileExtensions",[".png"]);
C = read(pxds);
categories(C{1})
B = labeloverlay(I,C{1});
imshow(B)
i have also labeled the image using imagelabeler app on database, the directory navigation everything is fine. but wen the code come to the labeloverlay part in the code, where the labeled image should be overlaying with the original image to show the overlay result i am enountering this error.
Error using labeloverlay
Expected A to be one of these types:
single, double, uint8, uint16, int16
Instead its type was matlab.graphics.primitive.Image.
Error in labeloverlay>parseInputs (line 131)
validateattributes(A,{'single', 'double', 'uint8', 'uint16', 'int16'},{'nonsparse','real','nonempty'},mfilename,'A');
Error in labeloverlay (line 88)
parsedInputs = parseInputs(varargin{:});
Error in semantic_seg (line 19)
B = labeloverlay(I,C{1});
i have tried converting the image to uint16->uint8, but still the same error.
i just have to get through the part where the labeled image should overlay with the original image, for the further sections of the algorithm i am good to go.
0 Comments
Answers (1)
Pratik
on 13 Feb 2024
Hi Goutham,
From what I can understand from the question, the code tries to overlay labeled image with the original image but there is an error in the “labeloverlay” function.
The error encountered is due to “I” being of type “matlab.graphics.primitive.Image” rather than an image matrix. This is because “imshow” returns a “matlab.graphics.primitive.Image” object, not the image data. The “labeloverlay” function expects an image matrix.
To fix the issue, image data from “imread” should be used directly.
I hope this helps!
0 Comments
See Also
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!