saalfeldlab / paintera

GNU General Public License v2.0
99 stars 17 forks source link

Mask resolution is not correct for non-isotropic data. #361

Closed hanslovsky closed 1 year ago

hanslovsky commented 4 years ago

It is possible to paint at higher resolution than the low resolution of non-isotropic CREMI data: paintera-brush-issue-(2) crop

I expect that this is not a problem with the brush but with the canvas.

hanslovsky commented 4 years ago

May be related to #342

cmhulbert commented 2 years ago

Recent changes to how Painting and Masks are used I believe solve this. @hanslovsky, @axtimwalde let me know if you think this gif seems to show this issue solved, or if you would expect different behavior:

PainteraIssue361

hanslovsky commented 2 years ago

I would expect that all the blue labels that are created by the line are connected, i.e. the individual components would need to be taller along the y axis of the viewer in this case. In the original issue comment, the painted area was overestimated. Here, it is underestimated. Basically, I would want every voxel painted that the brush overlaps with. I believe you may be checking for overlap with the center of a voxel only. I remember that I did not find a good (and efficient) way for collision/overlap detection of a cylinder with an arbitrarily rotated box.

axtimwalde commented 2 years ago

Good point to consider, we will drool over this a little longer. One way to interpret this could be that if you paint with a brush thinner than a pixel you get shapes that are thinner than a pixel and potentially disconnected. Another interpretation could be that for materializing into the mask, we have to loop over a raster that is the minimum of the resolutions of the screen mask and the label mask, that would fill those pixels but it may feel as slight overpainting again (by the thickness of the brush).

cmhulbert commented 1 year ago

With the most recent release, there where again significant changes to this. Now all voxels that the brush overlaps with are painted, and the resulting annotation will always be connected, regardless of the rotation. Here are a few examples:

https://user-images.githubusercontent.com/1859669/193656775-c6266a51-8eb3-467a-b68a-70d9e1468d94.mp4

https://user-images.githubusercontent.com/1859669/193656824-c808a608-04a2-42f9-995d-eb72db9e107b.mp4

@axtimwalde @hanslovsky let me know if you think this issue can be closed.

hanslovsky commented 1 year ago

I had a look at the frames when it flips from paint overlay to mask in the first video and it looks good to me. Do you have a link to the commit that fixed it? I am curious what the bug was.

axtimwalde commented 1 year ago

We are now painting into a 2D mask at screen resolution and at mouse release fill all voxels of the canvas that intersect with the screen and the mask.

cmhulbert commented 1 year ago

It's a fairly involved change, but if you want to look at the most relevant part of the commit, it's this particular function ViewerMask.applyMaskToCanvas.

hanslovsky commented 1 year ago

Awesome, thank you!