Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crop rotation fixes #410

Merged
merged 8 commits into from
Feb 23, 2021
Merged

Conversation

will-moore
Copy link
Member

@will-moore will-moore commented Dec 8, 2020

Fixes #408 - copy rotated crop region and paste to ROI.
Also fixes #324

Rectangle ROIs don't support rotation, but this fixes the issue above by creating a Polygon to simulate a rotated Rectangle.

To test:

  • Copy & Paste to duplicate a panel, then zoom in to crop, and rotate one of them.
  • Copy the Crop region and Paste it as a new Shape on the un-zoomed panel - The new Shape (Polygon) should match the crop region:

Screenshot 2020-12-08 at 21 55 42

  • Copy the rotated Crop region, select the uncropped (unrotated) Panel and click Paste to paste the rotated crop region. The rotation should also be applied to the panel so that both images show the same rotated viewport.
  • Crop the rotated panel using the "Crop" button. The 'initial' crop region should match the current viewport (see screenshot) and the updated crop region should be correctly applied to the panel.

Screenshot 2020-12-15 at 14 28 10

@will-moore will-moore changed the title Rotate rect to Polygon if crop region rotated ROI rectangle inset rotation fix Dec 8, 2020
@will-moore will-moore changed the title ROI rectangle inset rotation fix Crop rotation fixes Dec 15, 2020
@imagesc-bot
Copy link

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/omero-figure-box-annotations-rotated-incorrectly/45787/4

@pwalczysko
Copy link
Member

pwalczysko commented Jan 8, 2021

Copy the rotated Crop region, select the uncropped (unrotated) Panel and click Paste to paste the rotated crop region. The rotation should also be applied to the panel so that both images show the same rotated viewport.

Up till this point all worked. The above one I am not sure what to do with - where is the unrotated uncropped Panel ? I just used it in the previous step, and pasted the ROI on it, and it (the ROI, not the panel onto which I pasted) was rotated.... as I would expect. This seems to me like a repetition of the previous test, but now, surprisingly, a new result expectation (rotation of the unrotated panel) seems not reasonable - certainly there is some misunderstanding.

@will-moore
Copy link
Member Author

Copy the rotated Crop region, select the uncropped (unrotated) Panel and click Paste to paste the rotated crop region.

This means to use the "Paste" button at the bottom of the "Preview" Tab, to apply the same crop and rotation to the selected panel. This is NOT Pasting to create a new ROI as in previous steps.

@pwalczysko
Copy link
Member

Copy the rotated Crop region, select the uncropped (unrotated) Panel and click Paste to paste the rotated crop region.

This means to use the "Paste" button at the bottom of the "Preview" Tab, to apply the same crop and rotation to the selected panel. This is NOT Pasting to create a new ROI as in previous steps.

Thanks, got this one, and it works as expected.

@pwalczysko
Copy link
Member

Crop the rotated panel using the "Crop" button. The 'initial' crop region should match the current viewport (see screenshot) and the updated crop region should be correctly applied to the panel.

Sorry, struggling with this one too. Using the Crop button is clear, but should I first rotate and then Crop ? This means I should not zoom first ? Should I copy and paste the ROI somewhere ? If I do as told here, I am ending up with see screenshot below, how do I get the ROI displayed on the rotated image as shown on yours ?

Screenshot 2021-01-11 at 18 05 12

@pwalczysko
Copy link
Member

Crop the rotated panel using the "Crop" button. The 'initial' crop region should match the current viewport (see screenshot) and the updated crop region should be correctly applied to the panel.

After clarification, I was able to verify the above workflow too, it works fine.

Nevertheless, in this workflow, if the ROI does not come from the zoomed-in region but, is copied from another place in Figure (screenshot 1 below) or comes from OMERO (screenshot 2 below), this workflow still fails, as the copied or "from OMERO" ROIs are displayed unrotated.

Screenshot 1 (ROI copied from somewhere else in Figure and pasted (option "From Clipboard")

Screenshot 2021-01-12 at 11 17 17

Screenshot 2 (ROI from OMERO in Crop dialog, ROI should be rotated as the image is rotated)

Screenshot 2021-01-12 at 11 18 19

@pwalczysko
Copy link
Member

Would it be possible to fix also the Edit ROI panel view for rotated images ?

Workflow: Rotate an image in Figure. Click on "Labels" tab and "Edit" in the "ROI" row. Observe that the view in the Edit ROI dialog is unrotated, the image inside the panel on the canvas is rotated though.

Screenshot 2021-01-12 at 11 25 02

@pwalczysko
Copy link
Member

In summary, 3 RFEs : 2 RFEs regarding the crop dialog and rotation #410 (comment) and one regarding the Edit ROI dialog #410 (comment)

@will-moore
Copy link
Member Author

@pwalczysko I'm afraid fixing the "Edit ROIs" dialog to handle rotated images isn't easy since we'd need drawing tools to allow you to draw rotated Rectangles which I don't have (hand-coded drawing tools).

But the other 2 RFEs above should be fixed:

  • Open the crop dialog, having either copied a Crop Region from another Panel (with or without rotation) OR having copied a Rectangle. Also nice to have Rectangle ROIs saved on the Image in OMERO, and/or Rectangle ROIs on the Figure panel (see screenshot)
  • Check that each of these thumbnails shows the correct region of the image.
  • Clicking either the Rectangle ROIs from OMERO or the Rectangle on the figure panel (top and bottom sections of thumbnails) will set the Panel rotation to zero. Clicking the "clipboard" thumbnail will apply a rotation IF you copied the crop region from a Panel that was rotated.
  • When you hit "OK", any rotation that got applied should be saved (so that the crop region you selected was correctly applied to the image).

Screenshot 2021-01-22 at 10 36 09

@pwalczysko
Copy link
Member

pwalczysko commented Jan 22, 2021

@pwalczysko I'm afraid fixing the "Edit ROIs" dialog to handle rotated images isn't easy since we'd need drawing tools to allow you to draw rotated Rectangles which I don't have (hand-coded drawing tools).

I think this is fine. I would suggest a (couple of) short video(s) for the solution of the rotation and crop workflows would be very handy, as these workflows are very popular, but as the testing shows, not easy to get right on the first try.

Would you like to list for testing next week with my name ?

@pwalczysko
Copy link
Member

But the other 2 RFEs above should be fixed:

Open the crop dialog, having either copied a Crop Region from another Panel (with or without rotation) OR having copied a Rectangle. Also nice to have Rectangle ROIs saved on the Image in OMERO, and/or Rectangle ROIs on the Figure panel (see screenshot)
Check that each of these thumbnails shows the correct region of the image.
Clicking either the Rectangle ROIs from OMERO or the Rectangle on the figure panel (top and bottom sections of thumbnails) will set the Panel rotation to zero. Clicking the "clipboard" thumbnail will apply a rotation IF you copied the crop region from a Panel that was rotated.
When you hit "OK", any rotation that got applied should be saved (so that the crop region you selected was correctly applied to the image).

This works as expected. Ready to merge fmpov.

@will-moore
Copy link
Member Author

That last commit fixes an issue I noticed while preparing a demo movie: If you paste the crop region from a panel with 0 rotation, it didn't apply it to the new panel (it didn't remove the rotation on the target panel).

@will-moore
Copy link
Member Author

I made a demo movie for this PR:

crop_demo.mp4

@pwalczysko
Copy link
Member

@will-moore great movie, thanks, these are precisely the workflows which were picked upon in the recent workshop again, and the difference of those two Paste buttons is nicely shown

@jburel
Copy link
Member

jburel commented Jan 29, 2021

This could probably go to the official youtube channel otherwise it will be lost

@will-moore
Copy link
Member Author

Yes, can make the video more "public" when we release.
The last commit needs a test before merging: Copy the crop region from a non-rotated image (zero rotation) and paste as a crop region onto a rotated image. The rotation should be set to zero.

@pwalczysko
Copy link
Member

Copy the crop region from a non-rotated image (zero rotation) and paste as a crop region onto a rotated image. The rotation should be set to zero.

Tested
When I use the Paste buttion from Labels pane, the rotation is not set to zero. When I use the Paste button from Preview pane, the rotation is not set to zero. I guess this is the expected behaviour ?

@will-moore
Copy link
Member Author

When I use the Paste button from Preview pane, the rotation is not set to zero. I guess this is the expected behaviour ?

No. When I use the Paste button from Preview pane, the rotation should be set to zero.

@pwalczysko
Copy link
Member

When I use the Paste button from Preview pane, the rotation is not set to zero. I guess this is the expected behaviour ?

No. When I use the Paste button from Preview pane, the rotation should be set to zero.

Yes, the rotation on Pate is indeed set to zero. Sorry, typo (in my original report, there are two "no"s for both of the panes, in truth, I shoiuld have written "y" for the Preview pane, as this is what I saw.

Sorry

@pwalczysko
Copy link
Member

Inside the Crop dialog, copied a Rrectangle ROI from another panel which was rotated so that it is in Clipboard now.

the desciption above says

Clicking the "clipboard" thumbnail will apply a rotation IF you copied the crop region from a Panel that was rotated.

But when I click the Clipboard thumb it does not apply any rotation, instead, it unrotates the main panel in the Crop dialog and pastes the ROI correctly. Did this behaviour change (i.e. unitended change) or is it a misunderstanding ?

@will-moore
Copy link
Member Author

You copied a Rectangle ROI, but my text says "IF you copied the crop region..."
Rectangles can't have any rotation, but a crop region can.
The behaviour hasn't changed.

Does the thumbnail representation that you clicked look like the crop outline that is generated when you click it?

@pwalczysko
Copy link
Member

You copied a Rectangle ROI, but my text says "IF you copied the crop region..."
Rectangles can't have any rotation, but a crop region can.
The behaviour hasn't changed.

Does the thumbnail representation that you clicked look like the crop outline that is generated when you click it?

thanks for explaining.
No, the crop outline looks differently, the crop dialog is not showing the right thing now imho when Clipboard is selected.

Screenshot 2021-02-09 at 11 45 08

@pwalczysko
Copy link
Member

Compare the situation inside Crop dialog described in previous comment with the situation when I paste the crop region without using the Crop dialog on the same image.

Screenshot 2021-02-09 at 11 48 20

This behaviour seems right here, whereas the Crop dialog above #410 (comment) shows the wrong thumb and when thumb is clicked, a wrong rotation and position is shown in main panel.

@will-moore
Copy link
Member Author

Sorry @pwalczysko I can't seem to reproduce the bug you're seeing.
Can you point me at an example figure and exact steps to reproduce? Thanks.

@pwalczysko
Copy link
Member

pwalczysko commented Feb 12, 2021

The image used is (user-3)

https://merge-ci.openmicroscopy.org/web/webclient/?show=image-140172

The figure saved is

https://merge-ci.openmicroscopy.org/web/figure/file/70451

We clarified the workflow on a call - basically, taking the crop region from the zoomed in image, then selecting the non-zoomed non-rotated original image in the same figure and clicking on Crop button. In the crop dialog, the thumb of the Clipboard is wrong, as well as when this wrong thumb is applied onto the image, it is not where it should be either.

@pwalczysko
Copy link
Member

The problem #410 (comment) is fixed now.

Ready to merge fmpov.

@jburel jburel merged commit 169ca90 into ome:master Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ROI rectangle inset rotation rotate and crop errors
4 participants