
org.openimaj.image.feature.local.interest.InterestPointVisualiser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of image-local-features Show documentation
Show all versions of image-local-features Show documentation
Methods for the extraction of local features. Local features
are descriptions of regions of images (SIFT, ...) selected by
detectors (Difference of Gaussian, Harris, ...).
/**
* Copyright (c) 2011, The University of Southampton and the individual contributors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the University of Southampton nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openimaj.image.feature.local.interest;
import java.util.ArrayList;
import java.util.List;
import org.openimaj.image.FImage;
import org.openimaj.image.Image;
import org.openimaj.image.feature.local.keypoints.InterestPointKeypoint;
import org.openimaj.image.processor.SinglebandImageProcessor;
import org.openimaj.image.renderer.ImageRenderer;
import org.openimaj.math.geometry.shape.Ellipse;
/**
* Visualise the interest points extracted using an {@link InterestPointDetector}. Allows for points and areas of interest to be drawn
* @author Sina Samangooei ([email protected])
*
* @param
* @param
*/
public class InterestPointVisualiser & SinglebandImageProcessor.Processable> {
Q image;
List interestPoints;
/**
* Image from which interest points were extract and the extracted points.
* @param image source image
* @param keys extracted interest points
*/
public InterestPointVisualiser(Q image, List keys) {
this.image = image;
this.interestPoints = keys;
}
/**
* Extract ellipses from second moment matricies of interest point keypoints
* @param Image pixel type
* @param Image type
* @param image the image to visualise with
* @param keys the list of interest points
* @return a prepared visualiser
*/
public static & SinglebandImageProcessor.Processable>InterestPointVisualiser visualiseKeypoints(Q image, List extends InterestPointKeypoint extends InterestPointData>> keys){
List interestPoints = new ArrayList();
for(InterestPointKeypoint extends InterestPointData> k : keys){
interestPoints.add(k.location.getEllipse());
}
return new InterestPointVisualiser(image,interestPoints);
}
/**
* Extract ellipses from second moment matricies of interest point keypoints
* @param Image pixel type
* @param Image type
* @param image the image to visualise with
* @param keys the list of interest points
* @return a prepared visualiser
*/
public static & SinglebandImageProcessor.Processable>InterestPointVisualiser visualiseInterestPoints(Q image, List extends InterestPointData> keys){
List interestPoints = new ArrayList();
for(InterestPointData k : keys){
interestPoints.add(k.getEllipse());
}
return new InterestPointVisualiser(image,interestPoints);
}
/**
* Extract ellipses from second moment matricies of interest point keypoints
* @param Image pixel type
* @param Image type
* @param image the image to visualise with
* @param keys the list of interest points
* @param scale scale axis
* @return a prepared visualiser
*/
public static & SinglebandImageProcessor.Processable>InterestPointVisualiser visualiseInterestPoints(Q image, List extends InterestPointData> keys, double scale){
List interestPoints = new ArrayList();
for(InterestPointData k : keys){
interestPoints.add(k.getEllipse());
}
return new InterestPointVisualiser(image,interestPoints);
}
/**
* Draw the interest points, a central dot for in the pointCol and a bordered area of interest by borderCol.
* If either is null it is not drawn.
*
* @param pointCol
* @param borderCol
* @return image with patches drawn
*/
public Q drawPatches(T pointCol, T borderCol) {
Q output = image.clone();
ImageRenderer renderer = output.createRenderer();
for (Ellipse k : interestPoints) {
if(pointCol!=null){
renderer.drawPoint(k.calculateCentroid(), pointCol, 3);
}
if (borderCol != null) {
renderer.drawShape(k,borderCol);
}
}
return output;
}
public Q drawCenter(T col) {
Q output = image.clone();
ImageRenderer renderer = output.createRenderer();
for(Ellipse e : interestPoints){
renderer.drawPoint(e.calculateCentroid(), col,2);
}
return output;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy