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.

Image Demosaicing Quality in PlantCV versus LemnaBase

See original GitHub issue

I have been using PlantCV for a while now to analyse LemnaTec Scanalyser visible-spectrum images, but it has come to my attention that the quality of the images generated by PlantCV (using OpenCV functions) is not as good as the native LemnaTec software and I am unsure why.

Images are downloaded using a forked version of Data Science Tools (LT-db-extractor.py). For our system, we initially found that OpenCV image conversion number 47 (cv::COLOR_BayerGB2BGR) worked best for us. Here’s a close-up:

B2020001c13r01n001_2020-08-31 13-34-03_B2020001_0-deg_59290301_2291_0_Colour47

You can see, the quality isn’t great around the edges of the object. Let’s look at the same image exported via LemnaBase:

B2020001c13r01n001_2020-08-31 13-34-03_B2020001_0-deg_59290301_2291_0_LemnaTecPNG

Here the colours are better and edges sharper. In the past few days, I have played around with LT-db-extractor.py and changed the function on line 184 from:

img = cv2.cvtColor(raw_img, db['colour']) to img = cv2.demosaicing(raw_img, db['colour'])

I am not entirely sure what the difference between these functions is, but this change along with a modification in the OpenCV conversion format to #63 (cv::COLOR_BayerGB2BGR_VNG) has lead to considerable improvement:

B2020001c13r01n001_2020-08-31 13-34-03_B2020001_0-deg_59290301_2291_0_Colour63_demosaic

Whilst better, it’s still not quite as good as the LemnaTec software version (ie there is still some colour artifacts on the edges). I am trying to work out whether there is a problem with OpenCV’s image demosaicing process or some other factor. I have written a small Python script that will open a LemnaTec blob file and attempt to make all 143 conversions for easy comparison (of course most fail, but it generates a PNG of those that work for easy assessment).

The other thing I am trying to figure out is the format of the blobs. Do you know are they encoded and what actually sits within? Each seems to contain multiple images, encoded in some unknown format and the metadata seems to be obtained from the database via a SQL query. There is a “data” file in there, but what does that contain? In what format is it encoded?

So many questions, but some insight would be a great help.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nfahlgrencommented, Sep 16, 2020

For sure!

OpenCV bilinear vs colour-demosaicing Malvar: 0.93852859491338958 OpenCV bilinear vs colour-demosaicing Menon: 0.90777965142929185

comparison2

1reaction
nfahlgrencommented, Sep 16, 2020

Structural similarity index comparisons: OpenCV bilinear vs colour-demosaicing bilinear: 0.99711175070708258 OpenCV bilinear vs OpenCV EA: 0.99442848407307005 OpenCV bilinear vs OpenCV VNG: 0.82513981615385668

comparison

Read more comments on GitHub >

github_iconTop Results From Across the Web

Read Bayer Raw Image - PlantCV
Reads image into numpy ndarray and splits the path and image filename. ... to read images with Bayer mosaic pixel pattern and return...
Read more >
Image Demosaicing: Bilinear Interpolation VS High-Quality ...
In this story, I will explain two different algorithms in order to demosaic the images captured by a CCD camera and save based...
Read more >
Comparison of color demosaicing methods
The quality of the demosaiced image is finally evaluated by comparing it to the original image thanks to several objective error criteria.
Read more >
Comparison of color demosaicing methods - Semantic Scholar
A new demosaicking algorithm using the Kodak-RGBW CFA reduces noise and improves the quality of the reconstructed images by adding white pixels, and...
Read more >
Simultaneous demosaicing and resolution enhancement from ...
Figure 1.2 shows a real image after such interpolation stage, demonstrating the various image quality issues encountered in single-sensor color imaging. a: 3 ......
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