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.