views:

396

answers:

1

I've been beating my head against this for awhile to no avail.

I have a bunch of images of geological samples which are nominally 1500px wide by 30,000px long. A typical set of these images will number from 20-100. I have used the DeepZoomTools.dll to create a collection of these images and am attempting to use that to lay out the images.

All the images initially load with a ViewPort.Origin of 0 and a ViewPort.Width of 1 (basically the default). I'm iterating over them after the MultiScaleImage.ImageOpenSucceeded event and trying to arrange them based on some additional metadata.

Each image has an associated depth with it (depth as in meters), and I would like to stack each image based on that depth. (sometimes there can be a gap between the images, so I have to locate each image based on the top depth value). (See comments for an alternate explanation).

After I load a set of images I find the pixels per meter for the images themselves like this: (have to sum them all up as they are not necessarily contiguous)

double sumImagePixelHeights = (from s in _imageData.Values select s.Height).Sum();
double sumImageDepthRanges = (from s in _imageData.Values select (s.BottomDepth - s.TopDepth)).Sum();
_actualPixelsPerMeter = sumImagePixelHeights / sumImageDepthRanges;

Now with the pixels of the "full size" image per meter (depths are in units of meters) I determine what depth range I actually want to display (the y axis is scaled in depth):

double desiredVisiblePixels = (_MaxVisibleY - _MinVisibleY)*_actualPixelsPerMeter;
mainImage.ViewportWidth = desiredVisiblePixels / mainImage.ActualHeight;

This should set the viewport width such that I display the number of "original image pixels" that the depth range requires, scaling the displayed X range due to aspect ratio lock.

I then iterate over the images in the mainImage.SubImages collection to set their origin based on the desired depth.

for (int index = 0; index < mainImage.SubImages.Count; index++)
    {
      MultiScaleSubImage si = mainImage.SubImages[index];
      ImageMetadata im = _imageData[index];
      double xpnt = _actualPixelsPerMeter *im.TopDepth / (im.Width);
      si.ViewportOrigin = new Point(0, -xpnt);  
    }

The issue is:
The ViewportWidth calculation is incorrect - my images are scaled in ~3x what they should be (i.e. a "displayed depth range" of 10m displays an actual depth range of 3m)

I obviously have some bit of logic wrong in my calculations, but after going over it I'm just not seeing it.

I am setting the ViewportWidth on the entire multiscale image as opposed to setting it on just the subimages, but that seems to be fine as long as I don't want to adjust the viewport width relative to one another.

I have checked the depth values being parsed and passed in and they are correct.

A: 

The DeepZoom stuff, and especially Viewports, always makes my head hurt when I work with it. I'm not sure I can answer your question other than to point you in the direction of what helped me to get it.

One of the other resources that I found recently that I think is a lot easier to work with than the deep zoom tools themselves is Eventr. That tool makes creating and displaying deep zoom collections much easier.

Bryant
Both those links actually showed up as visited already, went back through them again and from Jaime's blog think this might be part of my issue: "ViewpointOrigin on Subimages: They are normalized relative to the viewportWidth of the subimage you are dealing with. " - still not sure though, have to dig back in after lunch.
Chris B
Yep, I had to scale my viewpoint origin by the width of the subimage, and not the viewable width of the current control - so removed that problem from above - just need to get the layout scale straightened out now.
Chris B
Marked this as answered as the key was that quote from jaime's blog re: viewpoint settings being relative to each subimage. The multiscale image viewport width just serves as a modifier to each subimages individual viewport width - basically I had to modify my desiredVieport by the ratio of each multiscale image's width with the width of the container. Ugh. But it works now, and thanks for the push in the right direction.
Chris B