ATH-MaaS/Pixelle-Video · error · ValueError

No suitable white column found within the specified range

Error message

No suitable white column found within the specified range

What it means

split_image searches a column range for white columns (used to split a composed two-panel image at its white divider) and raises ValueError when find_white_section returns nothing in that range. This means the assumed white gutter between the halves does not exist where expected.

Source

Thrown at pixelle_video/services/api_services/image_processor.py:94

                    white_sections.append((start_index, col))
                    in_white_section = False

        if in_white_section:
            white_sections.append((start_index, end))

        return white_sections

    def split_image(self):
        """将图片从中间分割为左右两部分"""
        start_col = self.width * 2 // 5
        end_col = self.width * 3 // 5
        white_sections = self.find_white_section(start_col, end_col)

        if white_sections:
            middle_section = white_sections[len(white_sections) // 2]
            mid_col = (middle_section[0] + middle_section[1]) // 2
        else:
            raise ValueError("No suitable white column found within the specified range")

        left_box = (0, 0, mid_col, self.height)
        right_box = (mid_col, 0, self.width, self.height)
        left_image = self.image.crop(left_box)
        right_image = self.image.crop(right_box)

        save_dir, filename = os.path.split(self.image_path)
        base, extension = os.path.splitext(filename)

        left_image_path = os.path.join(save_dir, base + '_front' + extension)
        right_image_path = os.path.join(save_dir, base + '_back' + extension)
        left_image.save(left_image_path)
        right_image.save(right_image_path)

        return left_image_path, right_image_path
    
    def stitch_images(self, image_paths, output_path):
        """拼接多张图片"""

View on GitHub (pinned to 848b054e4f)

Solutions

  1. Widen the start_col/end_col range to cover the actual gutter location.
  2. Relax the white-detection threshold in find_white_section (e.g. allow near-white >= 245 instead of 255) to tolerate compression noise.
  3. Verify the input is actually a stitched two-panel composite produced with matching dimensions.
  4. Log white_sections / column brightness to locate the gutter before calling split_image.

Example fix

// before
left, right = processor.split_image(0, processor.width // 2)  # gutter may be right of center

// after
left, right = processor.split_image(0, processor.width)  # search full width for the gutter
Defensive patterns

Strategy: validation

Validate before calling

def looks_like_composite(img) -> bool:
    w, h = img.size
    return w >= 2 * h * 0.5  # sanity: wide enough to be side-by-side
# verify range covers the gutter
assert 0 <= start_col < end_col <= processor.width

Type guard

def has_white_gutter(processor, start_col, end_col) -> bool:
    return bool(processor.find_white_section(start_col, end_col))

Try / catch

try:
    left, right = processor.split_image(start_col, end_col)
except ValueError:
    left, right = processor.split_image(0, processor.width)  # widen search range

Prevention

When it happens

Trigger: Calling split_image with a start_col/end_col range where no fully-white vertical column exists — e.g. images that are not side-by-side composites, colored/gradient gutters, gutter outside the given range, or compressed images with noisy (non-pure-white) dividers.

Common situations: Splitting an image that was never stitched by this library, threshold too strict for JPEG-compressed near-white columns, wrong start/end column bounds passed for a differently sized composite.

Related errors


AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30). Data as JSON: /api/errors/0d6803eb372104b7. Report an issue: GitHub.