Open
Conversation
8aa66b4 to
b98e218
Compare
b98e218 to
bb4c53f
Compare
With the same scan_file the loader due to caching gave back a mutable ScanImage. Moved caching to only the load Surface from scan-file, but makes every load a new ScanImage object.
409d83c to
e3485c2
Compare
Diff CoverageDiff: origin/main..HEAD, staged and unstaged changes
Summary
packages/scratch-core/src/computations/spatial.pyLines 19-28 19 x_min = max(0, x_coords.min() + margin)
20 x_max = min(mask.shape[1], x_coords.max() - margin + 1)
21
22 if x_min >= x_max:
! 23 raise ValueError("Slice results in x_min >= x_max. Margin may be too large.")
24 if y_min >= y_max:
! 25 raise ValueError("Slice results in y_min >= y_max. Margin may be too large.")
26
27 return slice(y_min, y_max), slice(x_min, x_max)src/preprocessors/controller.pyLines 29-40 29 scan_image: ScanImage, mark_type: MarkType, mask: BinaryMask, bounding_box: BoundingBox | None
30 ) -> Mark:
31 """Parse a scan file and extract a mark by rotating, cropping, masking, and resampling."""
32 if bounding_box is None:
! 33 logger.info("Masking and Cropping scan image")
! 34 scan_image_masked = Mask(mask=mask)(scan_image).unwrap()
! 35 scan_image_cleaned = FilterNeedles()(scan_image_masked).unwrap()
! 36 rotated_image = CropToMask(mask=mask)(scan_image_cleaned).unwrap()
37 else:
38 logger.info("Rotating Masking and Cropping scan image")
39 rotated_image = rotate_crop_and_mask_image_by_crop(scan_image=scan_image, mask=mask, bounding_box=bounding_box)
40 logger.info("Transforming scan image to mark") |
Minimum allowed line rate is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Filters:
-
FilterNeedles-
FilterMedianThese two are used in
rotation.pyI shuffeled the order a bit around to extract some logic like if No
bounding_boxis given then we dont need to rotate, but only crop and mask. by reordening i could extract that piece in put it in thecontroller.py. so we don't call a rotate function without the need for rotation. tests that were only cropping and masking not rotating are deleted. because we already coverd those tests and extrected that usecase.things i like to fix but didnt (yet).
i would like to extract
CropToMaskfrom therotate_crop_and_mask_image_by_cropso we could have a pure Rotation function. and create the pipeline without hiding buisness logic.stuff like making the margin bigger when rotation would be ideal to put it in the controller and not inside the execution.