Eliminate "spotlight" effect
Kresimir Majdenic from Croatia  [14 posts]
7 months
Actuall I have 2 problems:

1. I'm trying to get Xs (handwritten) from an image [Test5.jpg]. For that reason I try to "supress" everything "behind" Xs (grid lines, S,P,R,I letters). For that reason I do:

- Normalize (Equalize intensity, global area, Weight 100%)
- Contrast (-99)
- Crop Grids (using fiducials as position markers)
- AutoTreshold (Symmetry, 10%, Adjatment range minimum 5 and maximum 255, Black mask)
- Blob filter (Bigger than 150)

It works but results depends on light conditions. Camera have its own source of light (which, you can see on the image, have slight spotlight nature) but there is also impact from room light, ambient light (daylight), people passing by and making barely visible shadows etc.
Do you have any idea how to handle those "light" problems?

2. Barcodes (Code 128) do not get read each and every time. Sometimes it takes several pipeline runs before successful barcode read. Reading barcodes are important for whole process so I've tried to solve that by:

if BarcodeCount < 2 then RETURN

forcing RR to try again before I continue processing image.
Any idea why reading of 1D barcodes are so unstable?

Steven Gentner from United States  [260 posts] 7 months

1. Try using Adaptive Threshold instead of global threshold as that will be more localized to remove spotlight type lighting. You can play with the parameters and also with what appears black or white (Results checkboxes) to get what you need. You will find this to be more resistance to lighting than global thresolding or normalizing. Or if you prefer you can also try the flatten module which works similar to adaptive threshold but will not threshold the image. If you need more help isolating the X's let me know and we can provide an estimate of how long that would take.

2. Not sure why the barcodes are unstable. It possible the lighting for those is just under what they require. Can you post a couple images where the barcodes are not working? We can use those image to better understand why. The image you posted appears to work ok on a Code 128 extraction so we are not sure what that would fail without having an image to experiment with.

Kresimir Majdenic from Croatia  [14 posts] 7 months
Thank you very much for your kind reply.

1. I've applied Adaptive Threshold and indeed it's less sensitive to sudden light changes. It's much better but still if light conditions suddenly changes (hand shadow) it happens that background letters reappear from a second or two. Since system is constantly running reading of Xs can happen in that very moment leading to wrong readings. Is there any way to somehow remove those occasional appearance of "artefacts".
For instance, let's say that in 5 consecutive frames Xs are present all the time, "artefacts" (background letters and grid lines) appear in in frame 2 and 7 ... keep information present in all 5 frames and discard information not present in all 5 frames.
Furthermore, if it is possible ... how to know that pipline handled at least 5 frames and information is now ready and stable?

2. I've changed an algorithm and now if barcode does not get read correctly I return to the beginning of pipeline ... that way no further processing is done unless barcode is OK.
It's very difficult to provide "not OK barcode read image" since it's camera view and if not read correctly in frame 1 it keeps reading in the following frames and eventually it reads OK.
Kresimir Majdenic from Croatia  [14 posts] 7 months
In addition ... how to remove vertical and horizontal lines that, depending on light condition, appears after adaptive threshold as "artifacts" and pass BlobFilter "bigger than 150" and therefore lead to wrong readings
Kresimir Majdenic from Croatia  [14 posts] 7 months
If you need more help isolating the X's let me know and we can provide an estimate of how long that would take.
Can you please provide an estimate?
Kresimir Majdenic from Croatia  [14 posts] 7 months
After applying Flatten, Color-filter (gray color) and Blob filter I've managed to make it more prone to light/shadow changes.
Nevertheless I'd appreciate any other suggestions to improve readings even better.
Kresimir Majdenic from Croatia  [14 posts] 7 months
Unfortunately this turned out not to be true ... things changed in the morning when I tested it under daylight.

So I'm back to AdaptiveThreshold (10,20 ... min intensity 50 and max intensity 255, Black mask) ... this is least prone to shadows during daylight but now I'm from [Grid - before.jpg] stuck at this [Grid.jpg].
When BlobFilter by size is applied it works only when Xs are thick enough (not all pencils will provide sufficient thickness) to fit "size" condition. If I lower the size I get letters and grid lines as well.

Any idea how to isolate only Xs?

Kresimir Majdenic from Croatia  [14 posts] 7 months
I've ended up with

1. Salt_Pepper 10,50
2. Adaptive Threshold 20,10,30,200
3. Blob filter - bigger than 280

It works but if there is a better way I'd love to know it.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index