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

fix for pyramid.py #30

Open
ALAINRAAD opened this issue Jan 31, 2025 · 0 comments
Open

fix for pyramid.py #30

ALAINRAAD opened this issue Jan 31, 2025 · 0 comments

Comments

@ALAINRAAD
Copy link

you should fix the "create_laplacian_image_pyramid" in the pyramid.py .
it should be like this

def create_laplacian_image_pyramid(image, pyramid_levels):
    gauss_pyramid = []
    laplacian_pyramid = []

    gauss_pyramid.append(image)  # Start with the original image
    for i in range(pyramid_levels):
        down_image = cv2.pyrDown(gauss_pyramid[i])
        gauss_pyramid.append(down_image)

    for i in range(pyramid_levels):
        # Convert to 3 channels before subtraction (KEY CHANGE)
        current_level = gauss_pyramid[i]
        if current_level.ndim == 3 and current_level.shape[2] == 4: #Check if it has 4 channels
            current_level = current_level[:,:,:3] #Slice to 3 channels

        if i < pyramid_levels - 1: #Only upsample if it's not the last level
            higher_level_upsampled = cv2.pyrUp(gauss_pyramid[i + 1])
            if higher_level_upsampled.ndim == 3 and higher_level_upsampled.shape[2] == 4: #Check if it has 4 channels
                higher_level_upsampled = higher_level_upsampled[:,:,:3] #Slice to 3 channels

            laplacian_pyramid.append((current_level - higher_level_upsampled) + 0)  # Add 0 for type consistency.
        else:
            laplacian_pyramid.append(current_level)  # The last level is just the last Gaussian level.

    return laplacian_pyramid
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

1 participant