Skip to content
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

what stardard do you use in the color space conversion? #10

Open
wjtan99 opened this issue Dec 8, 2021 · 3 comments
Open

what stardard do you use in the color space conversion? #10

wjtan99 opened this issue Dec 8, 2021 · 3 comments

Comments

@wjtan99
Copy link

wjtan99 commented Dec 8, 2021

The conversion matrix is [0.257 0.504 0.098 16; -0.148 -0.291 0.439 128; 0.439 -0.368 -0.071 128]. What is this standard of your implementation?
In addition, have you implemented lens shading correction?
Thank you.

@wjtan99
Copy link
Author

wjtan99 commented Dec 8, 2021

Never mind, I found it in your document.
I did not find the LSC in your code. Did you implement it?

@cruxopen
Copy link
Owner

cruxopen commented Mar 5, 2022

Never mind, I found it in your document. I did not find the LSC in your code. Did you implement it?

Not yet, LSC was realized by some approximation functions. Didn't include it.

@Kuo-TingKai
Copy link

Never mind, I found it in your document. I did not find the LSC in your code. Did you implement it?

Not yet, LSC was realized by some approximation functions. Didn't include it.

Should we append the functionality of LSC such like this project?

class lens_shading_correction:
    def __init__(self, data, name="lens_shading_correction"):
        # convert to float32 in case it was not
        self.data = np.float32(data)
        self.name = name

    def flat_field_compensation(self, dark_current_image, flat_field_image):
        # dark_current_image:
        #       is captured from the camera with cap on
        #       and fully dark condition, several images captured and
        #       temporally averaged
        # flat_field_image:
        #       is found by capturing an image of a flat field test chart
        #       with certain lighting condition
        # Note: flat_field_compensation is memory intensive procedure because
        #       both the dark_current_image and flat_field_image need to be
        #       saved in memory beforehand
        print("----------------------------------------------------")
        print("Running lens shading correction with flat field compensation...")

        # convert to float32 in case it was not
        dark_current_image = np.float32(dark_current_image)
        flat_field_image = np.float32(flat_field_image)
        temp = flat_field_image - dark_current_image
        return np.average(temp) * np.divide((self.data - dark_current_image), temp)

    def approximate_mathematical_compensation(self, params, clip_min=0, clip_max=65535):
        # parms:
        #       parameters of a parabolic model y = a*(x-b)^2 + c
        #       For example, params = [0.01759, -28.37, -13.36]
        # Note: approximate_mathematical_compensation require less memory
        print("----------------------------------------------------")
        print("Running lens shading correction with approximate mathematical compensation...")
        width, height = utility.helpers(self.data).get_width_height()

        center_pixel_pos = [height/2, width/2]
        max_distance = utility.distance_euclid(center_pixel_pos, [height, width])

        # allocate memory for output
        temp = np.empty((height, width), dtype=np.float32)

        for i in range(0, height):
            for j in range(0, width):
                distance = utility.distance_euclid(center_pixel_pos, [i, j]) / max_distance
                # parabolic model
                gain = params[0] * (distance - params[1])**2 + params[2]
                temp[i, j] = self.data[i, j] * gain

        temp = np.clip(temp, clip_min, clip_max)
        return temp

    def __str__(self):
        return "lens shading correction. There are two methods: " + \
                "\n (1) flat_field_compensation: requires dark_current_image and flat_field_image" + \
                "\n (2) approximate_mathematical_compensation:"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants