[ome-devel] set pixels size Java API

Dominik Lindner (Staff) d.lindner at dundee.ac.uk
Wed Feb 6 11:07:28 GMT 2019


I had a look at the PixelsData class again. It's not really a bug,
but I'll update the documentation of the getPixelSize methods, to
make it clearer.
What happens is, if you call getPixelSizeX/Y/Z(UnitsLength.MICROMETER),
it does an explicit conversion into micrometers, hence the new Length object which
will have unit micrometer. That's not the original Length object, so won't be
updated/saved. If you want to set the pixel size, you'd have to use the
setPixelSizeX/Y/Z methods, e.g.:
pixels.setPixelSizeX(new LengthI(10, UnitsLength.MICROMETER));

Regards,
Dominik


> On 5 Feb 2019, at 23:28, Thomas Boudier <boudier.t at wehi.edu.au> wrote:
>
> Dear OMERO developers,
>
> I would like to update the pixels sizes for some images, I tried to
> convert in Java the code posted here
> https://www.openmicroscopy.org/community/viewtopic.php?f=6&t=7616&p=16966&hilit=pixel+size#p16966
>
> but it does not seem to work, there is no error, but the pixels sizes of
> the image is not updated in OMERO :
>
> public boolean setResolutionImageUM(ImageData imageData, double resXY,
> double resZ) {
>         try {
>             // get the pixels
>             RawDataFacility rdf =
> gateway.getFacility(RawDataFacility.class);
>             PixelsData pixels = imageData.getDefaultPixels();
>             // change their properties
>             Length pixelsX = pixels.getPixelSizeX(UnitsLength.MICROMETER);
>             pixelsX.setValue(resXY);
>             pixelsX.setUnit(UnitsLength.MICROMETER);
>             Length pixelsY = pixels.getPixelSizeY(UnitsLength.MICROMETER);
>             pixelsY.setValue(resXY);
>             pixelsY.setUnit(UnitsLength.MICROMETER);
>             Length pixelsZ = pixels.getPixelSizeZ(UnitsLength.MICROMETER);
>             pixelsZ.setValue(resZ);
>             pixelsZ.setUnit(UnitsLength.MICROMETER);
>             // update database
> gateway.getUpdateService(securityContext).saveObject(pixels.asIObject());
>         } catch (ExecutionException e) {
>             e.printStackTrace();
>             return false;
>         } catch (BigResult bigResult) {
>             bigResult.printStackTrace();
>             return false;
>         } catch (DSOutOfServiceException e) {
>             e.printStackTrace();
>             return false;
>         } catch (ServerError serverError) {
>             serverError.printStackTrace();
>             return false;
>         }
>
>         return true;
>     }
>
> Thanks for any help.
>
> Best,
>
> Thomas
>
> --
> /***************************************************************/
>       Thomas Boudier, Senior Research Officer,
>       BioImage Analysis, Dynamic Imaging Centre,
>       Walter and Eliza Hall Institute (WEHI), Australia.
> /**************************************************************/
>
>
> _______________________________________________
>
> The information in this email is confidential and intended solely for the addressee.
> You must not disclose, forward, print or use it without the permission of the sender.
>
> The Walter and Eliza Hall Institute acknowledges the Wurundjeri people of the Kulin
> Nation as the traditional owners of the land where our campuses are located and
> the continuing connection to country and community.
> _______________________________________________
> _______________________________________________
> ome-devel mailing list
> ome-devel at lists.openmicroscopy.org.uk
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel


The University of Dundee is a registered Scottish Charity, No: SC015096


More information about the ome-devel mailing list