-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add "crop" to the MoBIE spec #44
Comments
That sounds very good. And then I would suggest it is users responsibility to first add a source transform to, e.g. rotate, the source into a space where the crop can be expressed in Cartesian coordinates. We could think of adding functionality to, e.g. BigDataViewer playground or BigDataProcessor2, that makes it easy for the user to determine both the transform and the crop. (ping @NicoKiaru). |
Ok, should we go with:
?
Exactly. |
|
That's what it's called in python: https://www.programiz.com/python-programming/methods/built-in/slice |
As a consequence this functionality would enable nicely automated galleries of bookmarks.
|
Ok, I have added the crop transform to the spec now.
The |
What would you think would be the best strategy to make the cropped sources available in MoBIE? Would you list them as extra 'images'? or 'bookmarks'? I think it would also be beneficial to give each crop a 'name' or ID to be able to identify them (for example when used in a gallery). |
This depends on what you want to achieve. If it makes sense to look at the cropped source independently, then it can be provided as an extra image. If not, it should only be added to the bookmarks.
I think that's the case anyway; each source in the view will be listed. But let's see how this looks once we have the crop functionality in the viewer; I think it's much easier to discuss this when we have a working example already. |
One source can have multiple crop regions. Hence I see the need for an independent tag for those. Or would you suggest to define multiple sources from the same image but pointing to different crop regions? |
Currently that's what one would need to do I think as the transformations do not change the name of the sources. Adding them as an extra sources with the cropped default view to the dataset.json also could allow you to give them a name of your liking. I thus think that could be a good mechanism. However, I think the current spec requires that name of the source in dataset.json MUST be the same as the name in the xml. We would need to allow for them to be different in order to add the same source several times with different crops, because the names of the sources in dataset.json MUST be unique. |
Frankly, above comment was just a knee-jerk reaction 😄 Second thought is that this is not a good idea. The |
We could add an optional |
I think maybe that issues solves itself when we do this? Because then the name is automatically determined by the view that applies the transformation(s). |
I think we may need another field in the |
While I agree that we should do the change you proposed in #46 I don't think it solves the particular issue here:
Makes sense and I can add it. Do you think this should be mandatory or optional? If optional, what would be the default? I think |
Good point! Let's add an optional name to the transform. I guess the point would be to append this to the source name?
Yes, let's do optional with default true. Is "shiftToOrigin" the best name for the field? |
👍
Not sure; I can't think of anything better right now. |
I am now not so sure about whether we should append the name. |
Sorry, here is the place that I meant. |
I am also not sure what's the best solution here. I see the issues you bring up with append. At least for the issue of how names are concatenated, we could say that MoBIE does not introduce any separators, so that this is up to the user. |
Ok, I made the following changes to the spec:
@tischi let me know if you want to change any of this. |
I am thinking now that the "name" should maybe not be the name of the transform but rather of the transformed source(s). Thus it would be "names", being a list of the same length as the "sources". I am favoring "replace", because a convenience append mode could be implemented in the software that create the mobie projects (e.g. your python package). |
Yes, I agree that's much better. I will change it. |
Ok, I updated it. To summarize all the relevant changes:
Here's an example of the crop transform: "sourceTransforms": [
{
"crop": {
"min": [0.0, 0.3, 2.1],
"max": [1.0, 2.3, 3.9],
"sources": ["imageA", "imageB"],
"names": ["imA-cropped", "imB-cropped"],
"shiftToOrigin": true
}
}
] A full project with a crop transform can be found here: |
Cool! I finally found the time to look into that again. "shiftToOrigin": true will be depending on when the crop happens will be. |
An |
for debugging: could you please also add a bookmark where you only do the transformation without the crop? because then we can look there whether the crop bounding box makes sense. |
Yep that's in there already. |
Yes, just saw that! But I think you have a bug because in the crop you are not referring to the correct name of the transformed source:
|
I fixed it for you. |
oops, just realizing this looks like the raw data... |
@constantinpape @martinschorb xml:
json:
Currently, my code expects the source names in the dataset.json to be identical to the source names in the xml. Is that what we also require in the specification?! |
Yes, we also require it in the spec. @martinschorb, you will need to fix it in your code that writes the data, this pybdv function is useful here: https://github.com/constantinpape/pybdv/blob/master/pybdv/metadata.py#L843 |
Renaming the original sources to other names than what is specified in the xml is something we could implement but I would like to avoid it because we would loose compatibility with the current bdv-playground, see this issue: bigdataviewer/bigdataviewer-playground#186 |
@martinschorb is it OK for you if I just manually change the name of the cropped source in the xml such that I can proceed with the testing? |
I just did it 😸 , renamed source in: |
@martinschorb I think in principle it is working: |
cool. The goal would be that it is oriented along the |
I have to take care of a 5th year Kindergeburtstag now. I'm curious how it proceeds... |
I think I cannot do anything from my side right now. Maybe you could just fix above issues and add more of those crops and arrange them in a grid view and then we take it from there. |
Is it in a state that you can make it available via the beta update site? Or can you provide me a compiled jar? that would be very helpful so I can play with the transforms. |
I just pushed the latest master to MoBIE-beta (ping @K-Meech @KateMoreva) |
Looks good. |
One general thing we need to consider: how do we deal with varying crop sizes?
This probably looks terrible... I can see a couple of options:
How would you go about it? |
|
I would say lets go for this option. We already discussed at some point (and I cannot find the issue) that some optimal space filling algorithm for 2D tiles of different sizes could be a lot of fun to implement. |
Cool, I will check it out.
Yes, I would also vote for trying this first. I also couldn't find this issue, but it's easy to google: https://en.wikipedia.org/wiki/Rectangle_packing |
@tischi it stopped working with my crops ( Tried with the current beta on Mac and Windows. |
@martinschorb maybe this is because you have added |
I head this in earlier versions as well (see |
OK, found it. It was the "old" problem that the |
Looks like it works. But I cannot close this issue... |
Nice that it works! I will close it. |
As discussed in #32 and bigdataprocessor/bigdataprocessor2#168, it would be good to express a "crop" in the MoBIE spec.
I think the best option would be to add this as an additional source transform and/or viewer transform.
Let me know what you think, @tischi @martinschorb @K-Meech.
The text was updated successfully, but these errors were encountered: