libvips extract area of NDPI from Ex40 not from map - image

I am using libvips to get pyramids of .ndpi images.
through this answer and searching the documentation I found this command
vips extract_area myimage.ndpi[level=0] mypyramid.dz 0 0 10000 10000
Which extracts a crop starting at 0 0 and size 10000 10000 to a dzi file.
The level parameter is the magnification, 0 is the highest.
The problem is that the ndpi has the following images inside:
myimage_macro.tif
myimage_map.tif
myimage_x0.15625_z0.tif
myimage_x0.625_z0.tif
myimage_x10_z0.tif
myimage_x2.5_z0.tif
myimage_x40_z0.tif
And vips is taking myimage_macro.tif while I need myimage_x40_z0.tif
There should be a parameter like level to choose which from the images inside the OpenSlide (ndpi) I want.
Some people ask. Why not extracting the tif and then running vips?
Well, because vips tells me this:
openslide2vips: opening slide: No such value: directory 0, tag 278
Which means that using ndpisplit to extract the tif is somehow not saving the metadata to allow vips to recognize the image
So I am in a bit of a pesky situation. I have enormous images and I need to extract a slightly less enourmous piece and then have its pyramid.
Please help me, right now I am basically coding it all my self and it works but it is EXTREMELY slow.

I've written this as an answer, though it's not really an answer. It seemed too long as just a comment.
The libvips openslideload operation lets you pick an associated image to load. You can get a list of the associated images from the slide-associated-images metadata tag. For example:
$ vipsheader -f slide-associated-images 2013_09_20_29.ndpi
macro
$ vipsheader -f slide-associated-images CMU-1.svs
label, macro, thumbnail
You then pick out an associated image with perhaps:
$ vips crop CMU-1.svs[associated=label] x.jpg 10 10 100 100
To get a small part of the label.
So ... check what associated images openslide reports for your slide. If you can get the one you need, pick that with the associated parameter. If the image you need is not listed, I would contact the openslide project, since they will need to add support.
You could also check the openslide command-line tools, they might perhaps offer more options.

Related

Reverse Deep Zoom Image to high-res flat image

I have a collection of .dzi images (with corresponding split-up JPEGs) on my local computer. I want to reverse these images into a flat, hi-res image.
I googled, but couldn't find any software/scripts/tools to do this.
Any help?
Thanks,
Deckwasher
You can use a tool called dezoomify https://github.com/lovasoa/dezoomify which automatically generates a single high-res image based on a single tile image url.
It works for most tile server formats.
You can do this with libvips with:
vips arrayjoin "$(echo *.jpeg | sort -t_ -k2g -k1g)" x.tif --across 20
This will get all the xxx_yyy.jpeg files and sort them into row-major order (split the filename on _, sort by key 2 first), join into a big array 20 tiles across (you'll want to change this number) and write to x.tif.
It's fast and should work on images of any size.
It is certainly theoretically possible, but I don't know of any tool that does it directly. Basically you'd just want to take the highest resolution level and tile all the images back together.
You might take a look at this plugin for OpenSeadragon:
https://github.com/KTGLeiden/Openseadragon-screenshot
Set your viewer to the original image size and it should more or less do what you're looking for.

Any CLI tool to perform 3d texture mapping on the fly

I'm currently looking for a way to create a 'configurator' for a upholsters, similar to http://digitaldraping.com/configurator/furniture-sofa/?Cushions_Plain-Cream.png,Sofa_Stripe-Orange.png - you select your fabrics and they are 'drawn' on the sofa automatically.
Unfortunately, all the sites I've looked at seem to use pre-rendered transparent PNGs that are overlaid over each other to build up the full picture. The problem here is that we've figured out that we'd require over 120,000 different images to cover all models, fabrics etc!!
I've looked at a few 3d texture tools such as http://www.arahne.si/products/arah-drape.html, hoping that one of them would have a CLI option where you give it a pre-created wireframe, and a fabric to overlay, and it generates the required image on the fly, but so far everything seems to require real-time use of the GUI to use it.
So, is there a CLI tool that would do what I'm after, or can anyone suggest a way to manipulate the GUI automatically? (from a tech point of view, I'm comfortable with C, Bash, Python or PHP as a solution!)
Thanks!
ArahDrape 2.2 can now work from a command line without any GUI interface. You can also call ArahDrape as a C library. In this way, it can be used in a web server to create texture mapped images on the fly. The command line options are explained below.
ArahDrape 2.2j command line version, ©2015 Arahne
usage:
adCommand -o /tmp/outputImage.png -tN /home/user/texture.png [-hidemodel] [-divide 2] [-filterPNG] [-compressPNG 2] [-m /home/user/model.png] -owner name -activation 174b3cfb49e9 /home/user/project.drape
Input and output images can have png, .tif or .jpg extensions
-o output_image_file
-tN texture_image_file [N goes from 0 to 199]
-hidemodel will render all areas not in region as white
-divide N [N goes from 2 to 5] divide resulting image pixel size
-filterPNG if you do not filter it, rendering is faster
-compressPNG N [N goes from 0 to 9] lower number saves faster, but bigger files
-m model_image_file use this if you want to replace model image from the project; must have same pixel size
-owner owner_name pass the given owner name
-activation activation_code pass the given activation code
last parameter should be ArahDrape project file
All files should be entered with full path.
If you need spaces in filenames, use quotes "" around the filename.
If you provide only Owner name, without activation code, program returns registration code.
ArahDrape supports batch export.
Open ArahDrape project, click on texture you wish to replace, put all your texture in a directory, select from menu
Textures > Browse textures, and as you click the texture to load it, program will save the draped picture. If you have thousands of images, use keyboard shortcut = and program will automatically do them all.
Alpha channel transparency is supported in loading model images or textures, and saving the draped images, as long as you use PNG or TIFF.
Please check this video to see how
ArahDrape works in batch mode.
we (http://digitaldraping.com/) can do just what you are asking. We have two options creating images and rendering a meshed image on the fly. Just get in touch if you still need this solution.

Is it possible to check image dimensions without loading it [actionscript-3]?

I would like to check image size without downloading it (images are located on servers), is it possible? I found that great class http://www.anttikupila.com/flash/getting-jpg-dimensions-with-as3-without-loading-the-entire-file/ but its only for JPEG, and It would be nice to have something for png as well. That class was written 5 years ago, so was there created anything like that and/or for other kinds of images, since then? I searched google without luck.
Christophe Herreman claimed that he wrote something like this for PNG but after inspection - it's something essentially different.
You may start to load the file, read the bytes at the beginning of the file, get the dimensions from there and stop loading. Here is the PNG format specification. After 8 bytes of signature, you may find what you need.

Why only 1 image out of 2 is correctly read by tesseract?

It's my first experience with tesseract, I'm trying to read the digits contained in these tiff images:
http://imageshack.us/g/703/64553021.png/
As you can see they are in the same format and also same width/height. I don't know why tesseract returns the correct output only for the second image ("150") instead for the first one returns a blank output.
Maybe I should modify them to best fit tesseract? How? I can use Imagemagick if needed.
Thanks in advance.
In the readme they say:
In the executable, page layout analysis is enabled by default. You may need to turn it off to process small images. No command-line control for this yet. Sorry. See tesseractmain.cpp.
I think your images are too small, try editing the code (and recompile).

Very large images in web browser

We would like to display very large (50mb plus) images in Internet Explorer. We would like to avoid compression as compression algorithms are not what CSI would have us believe that they are and the resulting files are too lossy.
As a result, we have come up with two options: Silverlight Deep Zoom or a Flash based solution (such as Zoomify). The issue is that both of these require conversion to a tiled output and/or conversion to a specific file type (Zoomify supports a single proprietary file type, PFF).
What we are wondering is if a solution exists which will allow us to view the image without a conversion before hand.
PS: I know that you can write an application to tile the images (as needed or after the load process) and output them; however, we would like to do this without chopping up the file.
The tiled approach really is the right way to do it.
Your users don't want to download a 50mb file before they can start viewing the image. You don't want to spend the bandwidth to serve 50 megs to every user who might only view a fraction of your image.
If you serve the whole file, users will eventually be able to load and view it, but it won't run smoothly for most of them.
There is no simple non-tiled way to serve just a portion of an image unless you want to use a server-side library like imagemagik or PIL to extract a specific subset of the image for each user. You probably don't want to do that because it will place a significant load on your server.
Alternatively, you might use something like google's map tool to provide zooming and scaling. Some comments on doing that are available here:
http://webtide.wordpress.com/2008/08/27/custom-google-maps/
Take a look at OpenSeadragon. To make a image can work with OpenSeadragon, you should generate a zoomable image format which mentioned here. Then follow starting guide here
The browser isn't going to smoothly load a 50 meg file; if you don't chop it up, there's no reasonable way to make it not lag.
If you dont want to tile, you could have the server open the file and render a screen sized view of the image for display in the browser at the particular zoom resolution requested. This way you arent sending 50 meg files across the line when someone only wants to get an overview of the image. That is, the browser requests a set of coordinates and an output size in pixels, the server opens the larger image and creates a smaller image that fits the desired view, and sends that back to the web browser.
As far as compression, you say its too lossy, but if thats what you are seeing you are probably using the wrong compression algorithm or setting for the type of image you have. The jpg format has quality settings to control lossiness, and PNG compression is lossless (the pixels you get after decompressing are the exact values you had prior to compression). So consider changing what you are using as compression, and dont just rely on the default settings in an image editor.

Resources