Fix DPC border handling with CFA-aware padding (closes #31) - #32
Conversation
marianadeem-10xe
left a comment
There was a problem hiding this comment.
Thanks @wuyiulin. The fix and tests look good. Two changes are suggested in comments before merge.
| return self.pad_cfa(self.img) | ||
|
|
||
| @staticmethod | ||
| def pad_cfa(img): |
There was a problem hiding this comment.
One design suggestion: could you move pad_cfa() into util/utils.py as a plain function instead of using @staticmethod here? All helper functions in this repo are placed there, this design is common to all modules.
There was a problem hiding this comment.
Done. Moved pad_cfa() to util/utils.py as a plain function and updated the imports in the module and the tests.
| @@ -30,10 +30,25 @@ def __init__(self, img, platform, sensor_info, parm_dpc, save_out_obj): | |||
| self.save_out_obj = save_out_obj | |||
|
|
|||
| def padding(self): | |||
There was a problem hiding this comment.
padding function can be removed as it is unused.
There was a problem hiding this comment.
Removed. The loop-based apply_dead_pixel_correction() now calls pad_cfa() directly.
|
Should I apply the same change (moving |
Yes please. I missed it earlier. Apologies for the inconvenience. |
Added comment to disable pylint warning on `increase_indent`. The `indentless` argument is unused in the body but required to match the parent class's method parameters.
marianadeem-10xe
left a comment
There was a problem hiding this comment.
Changes Reviewed.
Closes #31. Port of the fix in 10x-Engineers/Infinite-ISP#50 (issue 10x-Engineers/Infinite-ISP#39).
Problem
apply_fast_dead_pixel_correction()relied on scipy'smode="mirror"to pad the rawmosaic. Same-color neighbours are 2 px apart, so at rows/cols 1 and N-2 the mirrored
neighbour is the center pixel itself and
img > max_value/img < min_valuecannever trigger. The loop version
apply_dead_pixel_correction()has the same bug viapadding()(np.pad(..., "reflect")on the mosaic).Fix
pad_cfa(): pads each of the 4 CFA sub-grids by 1 px with reflect(= 2 px on the mosaic), preserving Bayer phase.
pad_cfa()before filtering, cropdpc_imganddetection_maskback afterwards (so the debug count stays correct).padding()now usespad_cfa(), so the loop version gets the same fix and bothpaths stay bit-exact. Happy to drop this part if you'd prefer to keep the scope to
the fast path only.
Tests
New
tests/test_dead_pixel_correction.py(75 cases):pad_cfa()never mirrors a pixel onto itself and keeps Bayer phasepytest tests/test_dead_pixel_correction.pyOn
main, 40 of the failures are border defects left uncorrected (every positionwith row or col 1 / N-2, hot and dead); the remaining one is the
pad_cfa()test,since the method doesn't exist there.
On
in_frames/normal/ColorCheckerRaw_2592x1536_10bit_GRBG_100DPs_ISO100.raw(
dp_threshold: 80) the output is bit-identical before/after (95 detections),and runtime is unchanged, so no regression on existing assets.
pylint10.00/10.Note
Since the Reference Model is the basis for the RTL, the matching DPC block in
Infinite-ISP_RTL may need the same border handling to stay bit-accurate.
Pull request checklist:
ReadMe / Documentation: N/A (bug fix, no change to block diagram, results, or module description)