Skip to content
Snippets Groups Projects
Commit f90d9865 authored by SAEZ Theo's avatar SAEZ Theo
Browse files

Ajout de la classe Outline pour appliquer un filtre de contour sur les images...

Ajout de la classe Outline pour appliquer un filtre de contour sur les images et mise à jour de la classe Display pour l'utiliser.
parent e549d2c7
Branches
No related tags found
No related merge requests found
Pipeline #48839 passed
Showing
with 54 additions and 1 deletion
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
File added
File deleted
No preview for this file type
File added
No preview for this file type
......@@ -21,7 +21,7 @@ public class Display implements Initializable {
this.image = MatrixGrayImage.createImageFromPGMFile("images/luminy.pgm");
transform transformation = new DecreaseGrayLevels(5);
transform transformation = new Outline(0.025);
transformation.applyTo(this.image);
......
import java.util.ArrayList;
import java.util.List;
import javafx.scene.paint.Color;
public class Outline implements transform {
private double threshold;
public Outline(double threshold) {
this.threshold = threshold; // threshold détermine le seuil
}
public void applyTo(GrayImage image) {
for (int i = 0; i < image.getWidth(); i++) {
for (int j = 0; j < image.getHeight(); j++) {
modifyPixel(image, i, j);;
}
}
}
public List<GrayColor> SouthEastNeigbors(GrayImage image, int x, int y) {
List<GrayColor> neigborsList = new ArrayList<>();
if (x != image.getWidth() - 1) {
neigborsList.add(image.getPixelGrayColor(x+1, y));
}
if (y != image.getHeight() - 1) {
neigborsList.add(image.getPixelGrayColor(x, y+1));
}
return neigborsList;
}
public void modifyPixel(GrayImage image, int x, int y) {
GrayColor actualByte = image.getPixelGrayColor(x, y);
List<GrayColor> neigborsList = SouthEastNeigbors(image, x, y);
ByteGrayColor newColor = ByteGrayColor.BLACK;
for (GrayColor grayColor : neigborsList) {
if (Math.abs(grayColor.getLuminosity() - actualByte.getLuminosity()) > this.threshold) {
newColor = ByteGrayColor.WHITE;
}
}
image.setPixel(newColor, x, y);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment