How to delete level(s) from a blockedImage object?
조회 수: 2 (최근 30일)
Following the MATLAB guide for spatial referencing using blocked images, I am attempting to analyze a pyramidal 23-level SCN image file. It is a whole-slide image of a microscope slide. The fact that each level has a different aspect ratio (printed from table t) confirms what I already knew, which is that reading the file into MATLAB also pulls extra images for the slide label, macro image, and thumbnail image. bigimageshow() then tries to display these unwanted images, thinking that they are some of the coarse and mid-resolution image levels. You can see this in the output below, where it reads the slide label as the coarsest resolution level.
% Display the spatial referencing information at the finest level. The
% image size (specified by the |Size| property) matches the extents in
% world coordinates. Notice that the default image coordinate system puts
% the center of the first pixel at (1,1). Because the pixel extents are 1
% unit wide in each dimension, the left edge of the first pixel starts at
finestLevel = 1;
finestStart = bim.WorldStart(finestLevel,:)
finestEnd = bim.WorldEnd(finestLevel,:)
% Display the spatial referencing information at the coarsest level.
coarsestLevel = bim.NumLevels;
coarsestStart = bim.WorldStart(coarsestLevel,:)
coarsestEnd = bim.WorldEnd(coarsestLevel,:)
%% Verify Aspect Ratio
% Display the image size and aspect ratio at each level. The aspect ratio
% is not consistent, which indicates that levels do not all span the same
% world area. Therefore, the default assumption is incorrect for this image.
t = table((1:bim.NumLevels)',bim.Size(:,1),bim.Size(:,2), ...
'VariableNames',["Level" "Height" "Width" "Aspect Ratio"]);
%% Display Layers to Compare Spatial Extents
% Display the blocked image by using the |bigimageshow| function. Display the
% coarsest resolution level.
hl = bigimageshow(bim,'ResolutionLevel',coarsestLevel);
title('Coarsest Resolution Level (23)')
% Display image data at the default resolution level in the same
% figure window. By default, |bigimageshow| selects the level to display
% based on the screen resolution and the size of the displayed region.
hr = bigimageshow(bim);
title('Default Resolution Level')
My question is 1) how do I view or otherwise check which resolutions levels are the ones I need of the slide itself, and 2) how do I discard these levels from the blockedImage object to exclude them from any image processing I do later? I know that I can view levels one at a time with
by changing 'level' to be 1 through 23 (or however many levels an image has), but I have hundreds of these images, so finding a way to do this in a script in MATLAB would be ideal, rather than doing them by hand one at a time. I want to remove these extra levels/images before I perform registration and segmentation.
Ashish Uthama 2022년 5월 6일
I couldnt easily find info about the .SCN format, but since it looks like the default construction syntax works - I assume its some kind of TIFF file? If so, there might be something in the IMFINFO output that tells the specimen image apart from the others. If you have a sample file you can share somewhere - I/someone could take a quick look to see if there is some other meta data to programmatically determine which levels are required.
Once you have that, it might be best to create a one-time copy of the data using write() picking only the levels you need. This will remove the unwanted data, reduce total size and also give you the oppourtunity to control the file blocking to better suite your application (and also potentially add loss-less/lossy compression if required).