-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
82 spot analysis for peak intensity correction #87
Merged
bbean23
merged 32 commits into
sandialabs:develop
from
bbean23:82-spot-analysis-for-peak-intensity-correction
May 29, 2024
+2,425
−174
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
7f7cedc
add collaborative_dir setting, fix SpotAnalysis __name__ == "__main__…
bbean23 7f1e53b
start #82 spot analysis for peak intensity correction
bbean23 11641f9
add CroppingImageProcessor
bbean23 89a71e3
fix error with ImageAttributeParser subclass __init__ initialization
bbean23 cce3f96
add method to retrieve a logger function based on the log level
bbean23 5f5a10c
formatting
bbean23 5fd2559
add ExposureDetectionImageProcessor, add image_processor_notes to Spo…
bbean23 56f5498
add TestExposureDetectionImageProcessor
bbean23 d8fe94b
add AbstractAggregateImageProcessor and associated test
bbean23 4c14072
add AverageByGroupImageProcessor and associated unit test, fix Cachea…
bbean23 97d55eb
add write_json and read_json to file_tools.py
bbean23 04ba15d
more prototyping of the PeakFlux workflow
bbean23 4237aa4
fix AbstractAggregateImageProcessor and AverageByGroupImageProcessor,…
bbean23 a5ee42b
fix SpotAnalysisImageAttributeParser by fixing ImageAttributeParser
bbean23 4a5841f
more debugging options
bbean23 60093db
add SupportingImagesCollectorImageProcessor, other small code and for…
bbean23 ad46e21
add NullImageSubtractionImageProcessor.py
bbean23 de9f978
better comments in CacheableImage
bbean23 5b0c73d
add ConvolutionImageProcessor
bbean23 5c011b7
update AbstractFiducial->AbstractFiducials to indicate the plural nat…
bbean23 f7ac1fa
fix SpotAnalysisOperable
bbean23 eb141e5
add AnnotationImageProcessor, add PointFiducials
bbean23 2b7ad94
remove unused imports, fix test file location
bbean23 bd484e3
add BcsFiducial, BcsLocatorImageProcessor, RenderControlBcs
bbean23 da10f68
remove unused code from PeakFlux and CroppingImageProcessor
bbean23 66631a9
add addition comments
bbean23 0a7a5e5
updating docstrings as suggested in PR
bbean23 920663b
better comments and code order for SupportingImagesCollectorImageProc…
bbean23 a6d74a5
add descriptions for the various ImageTypes
bbean23 c75a80b
better AbstractFiducial.orientation description
bbean23 c80b85b
formatting
bbean23 918a09b
better method names and descriptions, to match the comments on PR #87
bbean23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add AnnotationImageProcessor, add PointFiducials
commit eb141e5f7a0e3ebd58fbbc923369d88cf4b93f37
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import numpy as np | ||
|
||
from opencsp.common.lib.cv.AbstractFiducials import AbstractFiducials | ||
import opencsp.common.lib.geometry.Vxyz as v3 | ||
import opencsp.common.lib.geometry.Pxy as p2 | ||
import opencsp.common.lib.geometry.RegionXY as reg | ||
|
||
|
||
class PointFiducials(AbstractFiducials): | ||
def __init__(self, style=None, points: p2.Pxy = None): | ||
""" | ||
A collection of pixel locations where points of interest are located in an image. | ||
""" | ||
super().__init__(style) | ||
self.points = points | ||
|
||
def get_bounding_box(self, index=0) -> reg.RegionXY: | ||
# TODO untested | ||
return reg.RegionXY.from_vertices(p2.Pxy((self.points.x[index], self.points.y[index]))) | ||
|
||
@property | ||
def origin(self) -> p2.Pxy: | ||
return self.points | ||
|
||
@property | ||
def orientation(self) -> v3.Vxyz: | ||
# TODO untested | ||
return np.zeros((3, self.points.x.size)) | ||
|
||
@property | ||
def size(self) -> list[float]: | ||
# TODO untested | ||
return [0] * len(self.points) | ||
|
||
@property | ||
def scale(self) -> list[float]: | ||
# TODO untested | ||
return [0] * len(self.points) |
61 changes: 61 additions & 0 deletions
61
opencsp/common/lib/cv/spot_analysis/image_processor/AnnotationImageProcessor.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import dataclasses | ||
from typing import Callable | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
from opencsp.common.lib.cv.AbstractFiducials import AbstractFiducials | ||
from opencsp.common.lib.cv.CacheableImage import CacheableImage | ||
from opencsp.common.lib.cv.fiducials.PointFiducials import PointFiducials | ||
from opencsp.common.lib.cv.spot_analysis.SpotAnalysisOperable import SpotAnalysisOperable | ||
from opencsp.common.lib.cv.spot_analysis.image_processor.AbstractSpotAnalysisImageProcessor import ( | ||
AbstractSpotAnalysisImagesProcessor, | ||
) | ||
import opencsp.common.lib.geometry.Pxy as p2 | ||
import opencsp.common.lib.opencsp_path.opencsp_root_path as orp | ||
import opencsp.common.lib.render.figure_management as fm | ||
import opencsp.common.lib.render_control.RenderControlPointSeq as rcps | ||
import opencsp.common.lib.tool.file_tools as ft | ||
import opencsp.common.lib.tool.log_tools as lt | ||
|
||
|
||
class AnnotationImageProcessor(AbstractSpotAnalysisImagesProcessor): | ||
def __init__(self): | ||
super().__init__(self.__class__.__name__) | ||
|
||
def _execute(self, operable: SpotAnalysisOperable, is_last: bool) -> list[SpotAnalysisOperable]: | ||
old_image = operable.primary_image.nparray | ||
new_image = np.array(old_image) | ||
|
||
for fiducials in operable.given_fiducials: | ||
new_image = fiducials.render_to_image(new_image) | ||
for fiducials in operable.found_fiducials: | ||
new_image = fiducials.render_to_image(new_image) | ||
|
||
cacheable_image = CacheableImage(new_image, source_path=operable.primary_image.source_path) | ||
ret = dataclasses.replace(operable, primary_image=cacheable_image) | ||
return [ret] | ||
|
||
|
||
if __name__ == "__main__": | ||
import os | ||
|
||
indir = ft.norm_path( | ||
os.path.join( | ||
orp.opencsp_scratch_dir(), | ||
"solar_noon/dev/2023-05-12_SpringEquinoxMidSummerSolstice/2_Data/BCS_data/Measure_01/processed_images", | ||
) | ||
) | ||
image_file = ft.norm_path(os.path.join(indir, "20230512_113032.81 5W01_000_880_2890 Raw_Testing_Peak_Flux.png")) | ||
|
||
style = rcps.RenderControlPointSeq(markersize=10) | ||
fiducials = PointFiducials(style, points=p2.Pxy(np.array([[0, 643, 1000], [0, 581, 1000]]))) | ||
operable = SpotAnalysisOperable(CacheableImage(source_path=image_file), given_fiducials=[fiducials]) | ||
|
||
processor = AnnotationImageProcessor() | ||
result = processor.process_image(operable)[0] | ||
img = result.primary_image.nparray | ||
|
||
plt.figure() | ||
plt.imshow(img) | ||
plt.show(block=True) | ||
bbean23 marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is nice There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! It's really handy for this sort of situation where:
|
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also do len(self.points) fyi. Not that this needs to be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like that more. Done!