dice icon indicating copy to clipboard operation
dice copied to clipboard

Subset locations: Error, either the image path is not valid, the file does not exist, or the path contains non-UTF-8 characters

Open cerja opened this issue 1 year ago • 1 comments

DICe version: 3.0-beta.8

I believe that this error code is thrown improperly when subset centroid locations in subsets.txt are defined such that the subsets themselves would cover an entire image edge-to-edge.

It seems rather, that DICe internals overestimate the image size based on provided subset locations and the above error gets thrown even when paths are properly defined.

Example: If the image height is h=213 px and subset size is w=15 px one could define a step size s=11 px so that the subsets would cover the image edge-to-edge. In this case a subset.txt would look something like this:

BEGIN SUBSET_COORDINATES x1 7 x1 18 x1 29 ... x1 205 ...

Considering w=15 and the last centroid is at y=205 the subset would span y values [198, 212] (assuming counting starts with 0, y=212 is the edge). This throws an error about image path being improperly defined even when it's not. Proof of this not being a problem is having an image with height h=221 defined with the same path, and applying the same subset locations, results in a completed solution.

Why 221 px? Well, if subsets were supposed to cover y length of 213 px, DICe will exit in an error if the image is not AT LEAST 221 px high when w=15. This is curious as it would seem that the points defined in subsets.txt are not centroids but rather edge points. as 205+15=220 (again assuming starting from 0, 220 is the edge) seems to be how the last subset is defined. This premise, however falls due to the fact that defining the first subset location below y=7 px again result in an error.

Assuming abovementioned symbols the height of the image should satisfy the following equation: h>=(n-1)*s+w where "n" is the number of subset locations along y axis. DICe however seems to expect an image of height h>=(n-1)*s+3/2w.

Also i tried to import the subset locations in the DICe GUI and they were positioned correctly.

A fair mention is that this can be solved with a bit of padding added to the images.

cerja avatar Apr 12 '23 14:04 cerja

Thanks for pointing this out. The problem was actually just a minor bug in how DICe only reads a window of the image around the subsets instead of the whole image. This is now fixed in this commit https://github.com/dicengine/dice/commit/892496b466f4ecc50679f21db39b46cb3ac36a77

And should be available in the next release of DICe (version 3.0-beta.9)

dicengine avatar Apr 14 '23 19:04 dicengine