Open scuniff opened 12 months ago
I don't think this matters. Close?
Sounds ok to me .
I did though look into the code some and got a basic understanding. The following example shows what the width of the new rectangle would be with and without double precision.
Referring to lines 130 – 138 and just focusing on the width calculation:
Dimension d = birdEyeView.getImageSize();
Rectangle rl = canvas.getBounds();
int sizeX = rl.width;
int sizeY = rl.height;
double vx = sizeX/d.width;
double vy = sizeY/d.height;
int x = (int) (vx*region.x);
int y = (int) (vy*region.y);
int w = (int) (vx*region.width);
Assume:
Canvas is 500x500 Image is 260x260 Region is 200x200
Then……
sizeX=500 // canvas d.width = 260 // image
then vx would be: double vx = sizeX/d.width;
vx = 1.9 // double precsion vx=1 // int precision
Assume: region.width=200
then width of new Rectangle would be: int w = (int) (vx*region.width);
w = 380 // with double precision w = 200 // with int precision
Is this difference between the 2 precisions ok??
Sorry, closed this by accident....
In file:
https://github.com/ome/omero-insight/blob/40566b97d28f9caf5720a55faf15c324a8c6e5de/src/main/java/org/openmicroscopy/shoola/agents/imviewer/browser/BrowserUI.java#L134
Regarding this code:
As is, the division is being done in integer precision. If double precision is really wanted then sizeX and sizeY need to be cast to double:
Example snippet:
Output:
no cast, d is 2.0 with cast, d is 2.5