Why are the labels rotated?

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);
Error using imageDatastore (line 139)
Cannot find files or folders matching: 'C:\Users\andra\Desktop\slike vrc\/nepravilno'.
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

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.
The code is directly from the website
So for calculating angles i need to look in the function labeloverlay?
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.
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.

Sign in to comment.

Answers (0)

Categories

Products

Release

R2023b

Asked:

on 7 Jun 2024

Commented:

on 12 Jul 2024

Community Treasure Hunt

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

Start Hunting!