[ome-users] omero Beta4: Displaying an image from omero in matlab

b.gerritsen at nki.nl b.gerritsen at nki.nl
Tue Feb 17 12:50:22 GMT 2009


Dear all,

Some of the omero matlab scripts in the trunk do not work for me. Displaying an image from omero in matlab failed for me. After checking out the api it looks like the getPlane() function was to blame as it has changed from the previous version:

(copied directly from the docs for beta4 )
---

byte[]   getPlane(long pixelsId, int z, int c, int t, Ice.Current current)
          Get the raw plane for the pixels pixelsId, this returns a 2d array representing the plane, it returns doubles but will not lose data.

---

The returned array is one-dimensional and not two as the comment states. Although I'm new to both omero and matlab, I wrote a matlab function (see below) that displays images from omero. It works for the tiff files that I'm uploading into omero. If there are better ways to do it, please let me know!

Thanks!
Bram Gerritsen


------------------------------------------

function drawImage(hostname, username, password, pixelsId)
omeroGateway = createOmeroJavaService(hostname, username, password);
pixels = omeroGateway.getPixels(pixelsId);
pixelType = pixels.getPixelsType.getValue.getValue.toCharArray;

plane = swapbytes (typecast (omeroGateway.getPlane(pixelsId, 0, 0, 0), pixelType)); % OMERO uses Big Endian whereas intel systems use Little Endian

sizeX = pixels.getSizeX.getValue;
sizeY = pixels.getSizeY.getValue;
total = sizeX*sizeY;

rgbImage = zeros (sizeX, sizeY, 3, pixelType);
for j=1:sizeY,
        for i=1:sizeX,
                rgbImage(i, j, 1)=plane ( (j-1)*sizeX + i);
                rgbImage(i, j, 2)=plane ( (j-1)*sizeX + i);
                rgbImage(i, j, 3)=plane ( (j-1)*sizeX + i);
        end
end

figure(1);
image (rgbImage);
drawnow;


More information about the ome-users mailing list