001/**
002 * Copyright (c) 2011, The University of Southampton and the individual contributors.
003 * All rights reserved.
004 *
005 * Redistribution and use in source and binary forms, with or without modification,
006 * are permitted provided that the following conditions are met:
007 *
008 *   *  Redistributions of source code must retain the above copyright notice,
009 *      this list of conditions and the following disclaimer.
010 *
011 *   *  Redistributions in binary form must reproduce the above copyright notice,
012 *      this list of conditions and the following disclaimer in the documentation
013 *      and/or other materials provided with the distribution.
014 *
015 *   *  Neither the name of the University of Southampton nor the names of its
016 *      contributors may be used to endorse or promote products derived from this
017 *      software without specific prior written permission.
018 *
019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
020 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
021 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
022 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
023 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
026 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
028 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029 */
030package org.openimaj.image.processing.restoration.inpainting;
031
032import java.util.Collection;
033
034import org.openimaj.image.FImage;
035import org.openimaj.image.Image;
036import org.openimaj.image.pixel.Pixel;
037import org.openimaj.image.pixel.PixelSet;
038import org.openimaj.image.processor.ImageProcessor;
039
040/**
041 * Interface defining an implementation of an inpainting algorithm. Inpainting
042 * algorithms are {@link ImageProcessor}s, but it is expected that a mask
043 * showing which pixels need to be painted is provided before the
044 * {@link #processImage(Image)} call.
045 * <p>
046 * {@link Inpainter}s are necessarily not thread safe, but implementations are
047 * expected to be reusable once the mask has been reset. <strong>It is expected
048 * that a call to one of the <code>setMask</code> methods is made before every
049 * call to {@link #processImage(Image)}.</strong>
050 * 
051 * @author Jonathon Hare (jsh2@ecs.soton.ac.uk)
052 * 
053 * @param <IMAGE>
054 *            The type of image that this processor can process
055 */
056public interface Inpainter<IMAGE extends Image<?, IMAGE>>
057                extends
058                ImageProcessor<IMAGE>
059{
060        /**
061         * Set the mask. The mask configures which pixels need to be painted.
062         * 
063         * @param mask
064         *            the mask image; should be binary, with 1 values where painting
065         *            needs to occur.
066         */
067        public void setMask(FImage mask);
068
069        /**
070         * Set the mask. The mask configures which pixels need to be painted.
071         * 
072         * @param width
073         *            the mask width
074         * @param height
075         *            the mask height
076         * @param mask
077         *            the mask pixels
078         */
079        public void setMask(int width, int height, Collection<? extends Iterable<Pixel>> mask);
080
081        /**
082         * Set the mask. The mask configures which pixels need to be painted.
083         * 
084         * @param width
085         *            the mask width
086         * @param height
087         *            the mask height
088         * @param mask
089         *            the mask pixels
090         */
091        public void setMask(int width, int height, PixelSet... mask);
092
093        /**
094         * Inpaint the given image, painting all the mask pixels set by a prior call
095         * to {@link #setMask(int,int,Collection)}, {@link #setMask(FImage)} or
096         * {@link #setMask(int,int,PixelSet...)}
097         * 
098         * @param image
099         *            the image to perform inpainting on
100         */
101        @Override
102        public void processImage(IMAGE image);
103}