[ome-devel] set pixels size Java API

Thomas Boudier boudier.t at wehi.edu.au
Tue Feb 5 23:28:37 GMT 2019


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.
_______________________________________________


More information about the ome-devel mailing list