All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.ojil.algorithm.Gray8Peak3x3 Maven / Gradle / Ivy

There is a newer version: 0.0.11
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.github.ojil.algorithm;

import com.github.ojil.core.Error;
import com.github.ojil.core.Gray8Image;
import com.github.ojil.core.Image;
import com.github.ojil.core.PipelineStage;

/**
 * Find local 3x3 peaks in the Gray8Image. A pixel is set to Byte.MIN_VALUE
 * if it is not equal to the local maximum.
 * @author webb
 */
public class Gray8Peak3x3 extends PipelineStage {
    /**
     * Scan the image and set all pixels not equal to the local 3x3 maximum
     * to Byte.MIN_VALUE.
     * @param imageInput input Gray8Image. Not modified.
     * @throws com.github.ojil.core.Error if input is not a Gray8Image.
     */
    public void push(Image imageInput) throws Error {
        if (!(imageInput instanceof Gray8Image)) {
            throw new Error(
                            Error.PACKAGE.ALGORITHM,
                            ErrorCodes.IMAGE_NOT_GRAY8IMAGE,
                            imageInput.toString(),
                            null,
                            null);
        }
        Gray8Image grayInput = (Gray8Image) imageInput;
        Byte[] bData = grayInput.getData();
        Gray8Image grayOutput = new Gray8Image(imageInput.getWidth(),imageInput.getHeight());
        Byte[] bDataOut = grayOutput.getData();
        for (int i=1; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy