Why are the labels rotated?
Show older comments
I am working on code in which the program must detect whether the spring is inserted correctly in the handle or not. I labeled all the pictures. when I run the code, I see that the label is rotated and not like the original picture. I also noticed that it doesn't pull the Spring_incorrect label into the image I'm also interested in the classNames part. if I write something completely different inside, it still pulls the label.
PS: how can i see all the pictures? it jsut pulls the first one.
dataDir = fullfile('C:\Users\andra\Desktop\slike vrc\');
imDir = fullfile(dataDir,'nepravilno');
pxDir = fullfile('C:\Users\andra\Desktop\test\LabelingProject\GroundTruthProject\PixelLabelData');
imds = imageDatastore(imDir);
classNames = ["Correct" "Spring" "incorrect" "Spring_incorrect"];
pixelLabelID = [1 2 3 4];
pxds = pixelLabelDatastore(pxDir,classNames,pixelLabelID);
I = read(imds);
C = read(pxds);
categories(C{1})
B = labeloverlay(I,C{1});
figure
imshow(B)



4 Comments
DGM
on 7 Jun 2024
It's hard to guess why some code does something without knowing what the code is.
If I had do guess, maybe it has something to do with calculating angles via atan() instead of atan2(), or maybe ignoring direction of the y-axis.
Andraz Bosilj
on 9 Jun 2024
DGM
on 9 Jun 2024
I don't have CVT, so I can't dig into it. I suspect that the problem is in whatever is generating the polygons. Somewhere along the way, something converts a pointlist representing a set of polygons into a raster image representing the labeled areas. I assume that's what's happening in the labeler.
At least the version of labeloverlay() in IPT does not handle polygon data, so unless there's some newer toolbox-dependent version, I don't think it's labeloverlay() that's to blame. I'm going to assume that labeloverlay() is being fed a simple raster image the same as in IPT. That means that the polygon is miscalculated before labeloverlay() ever gets called.
If you're just using the labeler app or handling things through a bunch of high-level tools like in the CVT demos (i.e. never manipulating any raster or vector data directly), then I'd have to suspect that there's a bug somewhere in the tools. Then again, I still don't know exactly what you're doing, and like I said, I don't have CVT, so I couldn't replicate your workflow anyway.
If you can replicate the problem with certain images or steps during the labeling process, I would suggest contacting support.
Divyajyoti Nayak
on 12 Jul 2024
Hi @Andraz Bosilj, I wasn't able to reproduce this issue with test images, it works as intended on my system. I think the issue lies in the label files you are using but I can't confirm that without looking at the files themselves. The Label data can't really 'rotate' as the label image and original image need to be of same dimensions. If possible, could you share a few of the files? That would be really helpful.
Answers (0)
Categories
Find more on Image Processing Toolbox 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!