[ome-users] question about Bio-Formats.

Curtis Rueden ctrueden at wisc.edu
Wed Apr 8 20:47:26 BST 2015


Hi Qi,

> But do you know could we build a thumbnail image by our defined size
> but not use the default size?

It might work to write:

  coreMeta = reader.getCoreMetadataList().get(0);
  coreMeta.thumbSizeX = myDesiredSizeX;
  coreMeta.thumbSizeY = myDesiredSizeY;
  thumbPlane = reader.openThumbBytes(myImageNumber);

But I didn't test this. If you look at the default openThumbBytes
implementation, it is merely doing a full openBytes and then scaling the
image [1]. So you could also do it the same way in your own code. Something
like:

  img = AWTImageTools.openImage(null, reader, sizeX, sizeY);
  img = AWTImageTools.makeUnsigned(img);
  thumb = AWTImageTools.scale(img, thumbSizeX, thumbSizeY, false);
  thumbBytes = AWTImageTools.getPixelBytes(thumb, little);

Or since you like MATLAB, maybe there is a more comfortable MATLAB way for
you, such as imresize [2].

Regards,
Curtis

[1]
https://github.com/openmicroscopy/bioformats/blob/develop/components/formats-api/src/loci/formats/FormatTools.java#L1217-L1220

[2] http://www.mathworks.com/help/images/ref/imresize.html


On Wed, Apr 8, 2015 at 1:58 PM, Qi Gong <qigong at gwmail.gwu.edu> wrote:

> Hello Curtis,
>
> Thank you very much. That is helpful. But do you know could we build a
> thumbnail image by our defined size but not use the default size? Thank you.
>
> Sincerely,
> Qi
>
> On Wed, Apr 8, 2015 at 2:46 PM, Curtis Rueden <ctrueden at wisc.edu> wrote:
>
>> Hi Qi,
>>
>> > That only only get me the size of whole image, but not the size of
>> thumbnail image.
>>
>> reader.getThumbSizeX()
>> reader.getThumbSizeY()
>>
>> Searching the Javadoc is a good way to find this stuff.
>> http://javadoc.imagej.net/Bio-Formats/loci/formats/FormatReader.html
>>
>> Regards,
>> Curtis
>>
>> On Wed, Apr 8, 2015 at 1:28 PM, Qi Gong <qigong at gwmail.gwu.edu> wrote:
>>
>>> Hello Curtis,
>>>
>>> That only only get me the size of whole image, but not the size of
>>> thumbnail image.
>>>
>>> Sincerely,
>>> Qi
>>>
>>> On Wed, Apr 8, 2015 at 2:17 PM, Curtis Rueden <ctrueden at wisc.edu> wrote:
>>>
>>>> Hi Qi,
>>>>
>>>> > now I don't know the size (width and height).
>>>>
>>>> Use reader.getSizeX() and reader.getSizeY().
>>>>
>>>> -Curtis
>>>>
>>>> On Wed, Apr 8, 2015 at 1:08 PM, Qi Gong <qigong at gwmail.gwu.edu> wrote:
>>>>
>>>>> Hello Sebastien,
>>>>>
>>>>> now I just use the command
>>>>> "reader = bfGetReader('C:\000_whole_slides\tissue40x-8B.ndpi');
>>>>> plane = reader.openThumbBytes(1);"
>>>>> to get the thumbnail. But the output is a vector. 12288 x1. in the
>>>>> bfGetPlane function, you use the reshape function to transfer it to 2-D
>>>>> image. But in that function we know the size of image. And now I don't know
>>>>> the size (width and height). Do you know how to transfer it to image? Thank
>>>>> you.
>>>>>
>>>>> Sincerely,
>>>>> Qi
>>>>>
>>>>> On Wed, Apr 8, 2015 at 5:45 AM, Sebastien Besson (Staff) <
>>>>> s.besson at dundee.ac.uk> wrote:
>>>>>
>>>>>>  Hi Qi,
>>>>>>
>>>>>>  all understood and this certainly makes sense.
>>>>>> The Bio-Formats API has a method to return bytes corresponding to a
>>>>>> thumbnail instead of a full plane, see
>>>>>>
>>>>>> http://downloads.openmicroscopy.org/bio-formats/5.1.0/api/loci/formats/FormatReader.html#openThumbBytes(int)
>>>>>>
>>>>>>  This method can be used in the same way that bfGetPlane() makes use
>>>>>> openBytes() to retrieve a single
>>>>>> plane. Here, the final array would have to be resized by the
>>>>>> thumbnail size, typically 128 x 128, instead
>>>>>> of the full plane dimensions
>>>>>>
>>>>>>  Note however that the way to get thumbnails for almost all of the
>>>>>> readers is to read the pixels data
>>>>>> and scale it internally. For very large WSI, calling this method will
>>>>>> likely be restricted to the same memory
>>>>>> limitations as reading full planes.
>>>>>>
>>>>>>  Best regards,
>>>>>> Sebastien
>>>>>>
>>>>>>  On 7 Apr 2015, at 15:53, Qi Gong <qigong at gwmail.gwu.edu> wrote:
>>>>>>
>>>>>>   Hello Sebastien,
>>>>>>
>>>>>>  Thank you for your email. I am sorry, my description was not clear.
>>>>>> It is not "1-by-1". Now I could extract some sub_area of image, but the
>>>>>> extracted image is *1-to-1 *pixel with WSI. What we want is a
>>>>>> thumbnail. In other word, we want to display the whole WSI or a large part
>>>>>> of WSI in a small size. Thank you.
>>>>>>
>>>>>>  Sincerely,
>>>>>>  Qi
>>>>>>
>>>>>> On Mon, Apr 6, 2015 at 6:37 PM, Sebastien Besson (Staff) <
>>>>>> s.besson at dundee.ac.uk> wrote:
>>>>>>
>>>>>>> Hi Qi,
>>>>>>>
>>>>>>>
>>>>>>>  Do you need a thumbnail
>>>>>>>
>>>>>>>
>>>>>>>   On 6 Apr 2015, at 22:11, Qi Gong <qigong at gwmail.gwu.edu> wrote:
>>>>>>>
>>>>>>>  Hello Sebastien,
>>>>>>>
>>>>>>>
>>>>>>>  Hi Qi,
>>>>>>>
>>>>>>>  Thank you your your reply. I think it is working.
>>>>>>>
>>>>>>>
>>>>>>>  Good to hear.
>>>>>>>
>>>>>>>   Now, I want to use BIO to get a WSI ( whole slide image) image.
>>>>>>> But as the WSI is to large more than 2 GB. I can't use bfopen to open it.
>>>>>>> Melissa told me a could use bfGetPlane to get the image.
>>>>>>>
>>>>>>>
>>>>>>>  Indeed, if the image is large enough, reading all the planes into
>>>>>>> memory like boffin does simply does not
>>>>>>> scale and you have to read selectively.
>>>>>>>
>>>>>>>   But it extract image is 1-by-1  pixel.
>>>>>>>
>>>>>>>
>>>>>>>  If you have a WSI, it is surprising that the command pasted in a
>>>>>>> previous thread would return a single pixel
>>>>>>> Can you give us the full dimensions of your image as given by
>>>>>>> >> r =  bfGetReader(‘\path\to\file);
>>>>>>> >> r.getSizeX()
>>>>>>> >> r.getSizeY()
>>>>>>>  >> r.getSizeZ()
>>>>>>> >> r.getSizeC()
>>>>>>>  >> r.getSizeT()
>>>>>>> Also, can you paste the command you use to retrieve this 1-by-1
>>>>>>> pixel array?
>>>>>>>
>>>>>>>   But some time, we need and thumb image of whole image. Do you
>>>>>>> know how to extract a 1-by-N image? That means, Extract the whole image
>>>>>>> (with size 10000x10000), but only display and save in 100x100 size. Thank
>>>>>>> you.
>>>>>>>
>>>>>>>
>>>>>>>  Just to be sure, do you want to read a thumbnail for the entire
>>>>>>> image? Or are you looking for a way to
>>>>>>> retrieve a tile i.e. a XY subset of the full image?
>>>>>>>
>>>>>>>   Sincerely,
>>>>>>> Qi
>>>>>>>
>>>>>>>
>>>>>>>  Best regards,
>>>>>>> Sebastien
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Apr 6, 2015 at 3:26 PM, Sebastien Besson <
>>>>>>> seb.besson at gmail.com> wrote:
>>>>>>>
>>>>>>>> Hi Qi,
>>>>>>>>
>>>>>>>>  the content of your java.opts looks valid (although you might
>>>>>>>> want to increase the
>>>>>>>> memory settings later). According to the MATLAB documentation, e.g.
>>>>>>>>
>>>>>>>> http://uk.mathworks.com/help/matlab/matlab_env/java-opts-file.html?refresh=true
>>>>>>>> you need to put this file either in the MATLAB startup folder or
>>>>>>>> under the `bin\arch` folder
>>>>>>>> under the MATLAB root path. Locally, I have a `java.opts` under
>>>>>>>> `~/Documents/MATLAB` for
>>>>>>>> instance.
>>>>>>>>
>>>>>>>>  Can you try either of these options and check the output of the
>>>>>>>> following command
>>>>>>>> >> java.lang.Runtime.getRuntime().maxMemory
>>>>>>>> reflects what it in your java.opts
>>>>>>>>
>>>>>>>>
>>>>>>>>  Sebastien
>>>>>>>>
>>>>>>>>   On 6 Apr 2015, at 19:53, Qi Gong <qigong at gwmail.gwu.edu> wrote:
>>>>>>>>
>>>>>>>>     Hello everyone,
>>>>>>>>
>>>>>>>>  Sorry for bother. I try to use  Matlab version of Bio-Formats.
>>>>>>>> But I face the memory problem, I know, we could add a time named java.opts
>>>>>>>> to solve the problem.
>>>>>>>>
>>>>>>>>  I put the file the java.opts into matlab folder as attachment.
>>>>>>>> But matlab still shows the warning. Could anyone help me check whether my
>>>>>>>> java.opts is correct or not? Thank you.
>>>>>>>>
>>>>>>>>  Sincerely,
>>>>>>>> Qi
>>>>>>>>
>>>>>>>>
>>>>>>>>     <matlab folder.png><memory warning.png><java.opts>
>>>>>>>> _______________________________________________
>>>>>>>> ome-users mailing list
>>>>>>>> ome-users at lists.openmicroscopy.org.uk
>>>>>>>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> ome-users mailing list
>>>>>>>> ome-users at lists.openmicroscopy.org.uk
>>>>>>>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>  --
>>>>>>> mobile phone: 2024060862
>>>>>>>  _______________________________________________
>>>>>>> ome-users mailing list
>>>>>>> ome-users at lists.openmicroscopy.org.uk
>>>>>>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> The University of Dundee is a registered Scottish Charity, No:
>>>>>>> SC015096
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> ome-users mailing list
>>>>>>> ome-users at lists.openmicroscopy.org.uk
>>>>>>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> mobile phone: 2024060862
>>>>>>  _______________________________________________
>>>>>> ome-users mailing list
>>>>>> ome-users at lists.openmicroscopy.org.uk
>>>>>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
>>>>>>
>>>>>>
>>>>>>
>>>>>> The University of Dundee is a registered Scottish Charity, No:
>>>>>> SC015096
>>>>>>
>>>>>> _______________________________________________
>>>>>> ome-users mailing list
>>>>>> ome-users at lists.openmicroscopy.org.uk
>>>>>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> mobile phone: 2024060862
>>>>>
>>>>> _______________________________________________
>>>>> ome-users mailing list
>>>>> ome-users at lists.openmicroscopy.org.uk
>>>>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> ome-users mailing list
>>>> ome-users at lists.openmicroscopy.org.uk
>>>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
>>>>
>>>>
>>>
>>>
>>> --
>>> mobile phone: 2024060862
>>>
>>
>>
>
>
> --
> mobile phone: 2024060862
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-users/attachments/20150408/5813af4f/attachment.html>


More information about the ome-users mailing list