question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pyvips | Best way to create large histology image of size 5000000X5000000 pixels.

See original GitHub issue

Hello, @jcupitt!

I am new to pyvips, I want to create a large image. Following steps, I have to take:

  1. Finding coordinates as the stage is not precise. Using NCC based matching.
  2. Making a large background image to overlay each image using their global coordinate.
  3. Saving it in dzi format (is it possible to view real-time stitching). I have tried all the three steps. I am stuck in last two part.

Issues:

  1. When I am overlaying next image the previous image vanishes. I have tried all this method from this post . Can you also explain what is the various mode of an argument? Attached example code
import sys
import random
from PIL import Image
import numpy as np
import pyvips

output_size = 2000
bg = pyvips.Image.black(output_size, output_size, bands=3)
tile1 = pyvips.Image.new_from_file('1805_corrected.jpg', access="sequential")
tile2 = pyvips.Image.new_from_file('1806_corrected.jpg', access="sequential")
vips_image1 = tile1.embed(0, 0, output_size, output_size)   
vips_image2 = tile2.embed(1000,1000, output_size, output_size) 
vips_image=vips_image1.composite(vips_image2,["over"])
vips_image.write_to_file('vi_1.tiff')

  1. My data size would be very large, what would be the best way to mosaic this images?
  2. In the past, I have used Image.join function to create mosaic but the problem was when I exceed certain limit .dzsave takes lots of time and sometimes segmentation fault occurs.
  3. Is there any method in pyvips to match images two find coordinates for matching?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:41 (21 by maintainers)

github_iconTop GitHub Comments

1reaction
jcupittcommented, May 16, 2018

Hello again, could you make a new issue? It’s best to have one question per issue or other people will have trouble finding answers.

Include a complete runnable program and notes on how to make input data.

1reaction
jcupittcommented, May 3, 2018

Hello @shivamchaubey,

Wow, that’s a big image. If you want to paste many small images together at arbitrary positions, use insert. You will find there is a limit of about 2,000 images, set by the C stack size. You will probably have to assemble your image in sections.

If you can place the images in a grid, use arrayjoin. It can join at least 30,000 images at once.

composite is useful if your images have transparency. If you use it for images without an alpha channel, each image will just overwrite the previous one.

Yes, libvips has stuff for NCC-style matching, both 0 and 1st order. You make a series of pairwise joins along edges. It may not work for you, you’d need to give more information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image — pyvips 2.2.1 documentation - GitHub Pages
If the input object is an array-like object, a new image is created from the object's data ... Place an image within a...
Read more >
Competition: TissueNet: Detect Lesions in Cervical Biopsies
We found that reading the pyramidal TIFs using PyVips was a reliable way to work with the images in our machine learning pipelines....
Read more >
(Live) viewing of large images using pyvips - Stack Overflow
I first determine the total width and height of the full image and initialize a black image of the correct size and subsequently...
Read more >
Data Science - Resources and Tools - IBM Developer
It can be used to make predictions and decisions using analytics and machine learning. Select. Trending ...
Read more >
5 Ways to Make Histopathology Image Models More Robust to ...
When the domain shift is too large, a model trained on one type of data will fail on another, often in unpredictable ways....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found