Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting grid like pattern after image stitch many tiff files. #166

Open
kuldeep203 opened this issue Dec 10, 2022 · 5 comments
Open

Getting grid like pattern after image stitch many tiff files. #166

kuldeep203 opened this issue Dec 10, 2022 · 5 comments

Comments

@kuldeep203
Copy link

I have many microscope images. i have stitched all the images but getting line between the two images and one image overlap with other due to which my stitched images seems to be blured. i am attaching the image for your reference.
microscope
can you suggest me what i am missing. thanks in advance for helping.

@jmuhlich
Copy link
Collaborator

I think you need the --flip-y option which flips the tiles before stitching.

@kuldeep203
Copy link
Author

kuldeep203 commented Dec 10, 2022

I am again getting the same results as previous one. i am attaching my code.

from ashlar import fileseries, thumbnail, reg
import numpy as np

from tifffile import imread, imwrite, TiffFile

readers = []
for i in range(3):
    readers.append(fileseries.FileSeriesReader(
        '/home/kuldeep/Downloads/Inferencing_with_Button/Input/',
        pattern='image_{series:3}.jpg',
        overlap=0.1,
        width=11,
        height=1,
        layout='snake',
        direction='horizontal', )
    )
print(len(readers))
aligner0 = reg.EdgeAligner(readers[0], channel=0, filter_sigma=15, verbose=True)
aligner0.run()

mosaic_args = {}
mosaic_args['verbose'] = True
mosaic_args['flip_mosaic_y'] = True
aligners = []
aligners.append(aligner0)

mosaics = []
for j in range(1, 2):
    aligners.append(
        reg.LayerAligner(readers[j], aligners[0], channel=j, filter_sigma=15, verbose=True)
    )
    aligners[j].run()
    print("aligners[0].mosaic_shape", aligners[0].mosaic_shape, aligners[0])
    mosaic = reg.Mosaic(
        aligners[j], aligners[0].mosaic_shape, None, **mosaic_args
    )
    mosaics.append(mosaic)
print(type(mosaic))
writer = reg.PyramidWriter(mosaics, r"/home/kuldeep/Downloads/Inferencing_with_Button/16*16.ome.tif",
                           verbose=True)
writer.run()

@jmuhlich
Copy link
Collaborator

Sorry, I meant --flip-y on the command line, not --flip-mosaic-y which is what you used there -- they are subtly different. To implement flip-y in your script, add these lines after constructing the readers list:

for r in readers:
  r.metadata._positions = r.metadata.positions * [-1, 1]

(note this assigns back to _positions not positions)
You do not need to use mosaic_args['flip_mosaic_y'] = True at all.

However a bigger issue is that your example image appears to show a 17x17 grid but your FileSeriesReader arguments say width=11, height=1. It seems like you should actually be passing width=17, height=17 but perhaps there are other parts of your processing pipeline not shown here.

Would you mind sharing your images so I could take a closer look?

@jmuhlich
Copy link
Collaborator

jmuhlich commented Dec 11, 2022

One other tip: to paste multiple lines of code in a comment here, wrap it in three back-quotes on each end, not one. Single back-quotes are for highlighting an inline code statement and do not work for multiple lines. I edited your comment accordingly to make the code easier to read.

@kuldeep203
Copy link
Author

Thanks for the reply. Actually in the code it was 17*17. and it stitched well except grid like structure and second thing at stitched part pic is more blurred.
i am attaching the picture for your reference. due to size limit not able to attach 17x17. so just attached 17x3.
Input (17x3).zip
Thanks for your continue support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants