Introduce explicit image-format tracking through the pipeline to unify mono/bayer/color handling
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- numpy, python, testing-qa
- Domain
- computer-vision, machine-learning, testing-qa
Research direction
Start with instrument/common.py, silcam.py, process.py, and classify_torch.py to understand where image format is currently inferred from shape. Trace the loaders that should populate data['image_format'], then locate the existing tests for instrument loading and processing. Done means shared format-aware helpers replace the separate shape branches and tests cover mono8, Bayer, and synthetic 2D/UVP-like inputs end to end.
Written by the indexing model from the issue text.
Description
Supersedes/links #372 and #361, which both trace back to the same root cause.
Problem: nowhere in the pipeline is there a persistent, explicit tag for what kind of image is being processed. SilCamLoad knows the format at load time (dispatches on file extension: .silc→RGB8, .msilc→MONO8, .bsilc→BAYER_RG8, .bmp→inferred), but that information is discarded the instant load_image() returns — only the raw array and its incidental shape survive into data['imraw'].
Downstream, at least four separate places infer dimensionality from array shape instead of from an explicit type:
ImagePrep(silcam.py) —np.min(image, axis=2)has no dimension check, and raises an AxisError on 2D grayscale images (#361).statextract(process.py) —if imc.ndim == 2: imc = np.stack([imc]*3, axis=2), with a logged warning. This duplicates the single channel three times to produce a 3-channel array, restoring the expected shape but not actual color information (#372).classify_torch.py's_percentile_normalize— implements its own separate ndim/shape branch for the same case, independent of the above.instrument/common.py'sapply_circular_mask— also branches onlen(image.shape)==3; this one works, but via the same shape-inference approach.
Holo and UVP don't currently hit this ambiguity, because their data is never variable in shape: holo always builds 3D reconstruction stacks reduced via fixed ops, and UVP vignettes are always 2D, so every UVP image already goes through statextract's 2D-handling branch as its normal path rather than as an edge case. SilCam is the only instrument that produces different shapes depending on sensor format while sharing one downstream pipeline across them.
There is currently no test coverage for mono8/bayer/2D image paths.
Proposed approach:
- Have each instrument's
Loadstep set an explicitdata['image_format']tag (SilCam already knows this; holo/uvp would set a fixed value since they're always mono). - Add shared, format-aware helpers to
instrument/common.py(e.g.to_grayscale(image, image_format),ensure_three_channel(image, image_format)) to consolidate the separate implementations above into one tested path. - Each instrument's steps use only the helpers relevant to it — e.g. SilCam's
ImagePrepcallsto_grayscale;statextract/the classifier callensure_three_channelinstead of two independent implementations. - Add tests for
.msilc,.bsilc, and synthetic 2D/UVP-like arrays end-to-end, since none exist today.
This also supports the separation Raymond raised on #372 — particle-dimension measurement and classifier-input normalization become distinct, independently testable concerns instead of one shared shape inference.
- Dominant language
- Jupyter Notebook
- Stars
- 19
- Forks
- 7
- Avg merge
- 10d 11h
- Merged PRs (30d)
- 1
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SINTEF/pyopia
-
Guard clean_bw against the scikit-image remove_small_objects change before lifting the <0.25 pinMay be free again @riyagoyal01 claimed this 12 days ago, and no pull request is open. Openpatch / enhancement testing
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Use explicit, per-instrument-configurable timestamp format when parsing filenames (SilCam/Holo/UVP)Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 60/100
-
patch / enhancement priority-medium
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Document running Python directly in the Docker image, and which functions are publicPossibly taken @emlynjdavies claimed this 17 days ago. Opendocumentation question
Similar issues
-
Difficulty 2/5 Half a day Newbie friendliness 78/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
liberation-data/fornax4j#302 ·
Maintainers usually reply within 1 day
-
documentation enhancement lane:infra size:S status:ready
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
kornia/kornia-rs#1563 · 3 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
RapidAI/RapidOCRLite#3 ·