Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Need to remove artifacts

Solved!
Go to solution

Hello, I'm working with some images that were captured with a faulty lens. For this reason, there are regular black vertical lines on the attached image, which I define as artefacts.
Having reached this point I would like to ask you if you can give me suggestions on how to work with labview with the original image (not with the binary image, the threshold works well) in order to remove the artifacts and save it again without artefacts.
I have attached some images but there are over 10,000 images and the artefact varies (from vertical to horizontal and in position), so I don't know how to approach it in labview.
I am not attaching a .vi file as I don't need help in creating the .vi but just to understand which block to use and how.
Looking forward to your help, thanks a lot in advance

0 Kudos
Message 1 of 8
(950 Views)

It looks like the missing areas are two pixels wide.  I would consider using grayscale dilate and erode to fill them in.  There might be a close option that does them in order.

 

If you have a lot of salt and pepper pixels, this won't work as well.  It looks the missing pixels are always in the same area, so you could create a mask where you just do the grayscale morphology on the missing pixel area.

 

Are these the original grayscale image or the thresholded version?  It will be easier to fix in the original image.  One way or another, you want to replace the missing pixels with the surrounding values.

 

Bruce

Bruce Ammons
Ammons Engineering
Message 2 of 8
(922 Views)

@Nunzio1999 wrote:

Having reached this point I would like to ask you if you can give me suggestions on how to work with labview with the original image (not with the binary image, the threshold works well) in order to remove the artifacts and save it again without artefacts.
I have attached some images but there are over 10,000 images and the artefact varies (from vertical to horizontal and in position), so I don't know how to approach it in labview.


Since these faulty pixels seems to be in exactly the same locations across all images, you know where to correct. I would just iterate over all rows and, for each fault, a do a linear interpolation between the good pixels and maybe sprinkle the typical noise on top. that should be very fast and I would guess that the file IO would be the bottleneck.

 

You mention LabVIEW. This can all be done in simple code and you don't even need the vision tools.

0 Kudos
Message 3 of 8
(915 Views)
Solution
Accepted by topic author Nunzio1999

@altenbach wrote:
You mention LabVIEW. This can all be done in simple code and you don't even need the vision tools.

Here's a very quick draft. You can easily substitute different interpolations, this just does "nearest".)

It should rattle through your 1k images in no time. (note that your bmp are simple and you could extract and write the binary U8 data directly, saving you the huge detour over LabVIEW image data. Would be significantly faster! (not shown))

 

altenbach_0-1715624515356.png

 

Message 4 of 8
(879 Views)

@altenbach wrote:

It should rattle through your 1k images in no time. (note that your bmp are simple and you could extract and write the binary U8 data directly, saving you the huge detour over LabVIEW image data. Would be significantly faster! (not shown))


Here's how that could look like. It is significantly faster! (Pure 1D binary data, binary file IO, all operations in place for the main array.)

Note that the BMP header is retained "as is". note that all you really need is replace two elements in the innermost loop.

 

All you need to adjust is the folder and pattern selection, maybe replace with a folder dialog.

 

altenbach_0-1715631786764.png

 

 

 

 

altenbach_0-1715629116876.png

 

 

Message 5 of 8
(872 Views)

@Nunzio1999 wrote:

Hello, I'm working with some images that were captured with a faulty lens. For this reason, there are regular black vertical lines on the attached image, which I define as artefacts.
...
I have attached some images but there are over 10,000 images and the artefact varies (from vertical to horizontal and in position), so I don't know how to approach it in labview.
 advanc


This is definitely not a lens artifact, but a sensor artifact. All your images have identical artifacts, and if they really vary, you should have attached a variety of images! Are they always confined to a quadrant? Are they always two pixels wide? Do they always have the same spacing?

 

My code could be easily adapted to detect and remove these kind of artifact, but the more we know, the easier it will be. Of course it could even overwrite the input file, but that's not desirable during development and debugging.

0 Kudos
Message 6 of 8
(853 Views)

Thank you very much for your answer and your help, I used your first example and adapted it for 2 or 3 cases.
I apologize for the imprecision, I said "lens artifact" instead of "sensor artifact", however the problem does not only exist on one quadrant, in these images for example it is less accentuated but it covers the entire quadrant.
You can notice vertical bands on all images throughout the image.
Anyway, thanks so much for the help because I really had no idea how to work with .bmp files directly as pixmaps before your post.

0 Kudos
Message 7 of 8
(797 Views)

This seems like a completely different artifact and seems to have some periodic background that is the same for each row. This requires a very different treatment, but again seems to be about the same for all image. See if you can average all rows and get a better idea how that pattern looks like. Simplify it to a function and subtract it from all rows.

 

Why not just replace the sensor? 😄

0 Kudos
Message 8 of 8
(795 Views)