Merge branch 'main' into 'besoin8'
# Conflicts: # backend/src/main/java/pdl/backend/ImageProcessing.java
This commit is contained in:
commit
524c7bb9e9
3 files changed
+25
-39
No files matched your search
+1
-1
@@ -59,7 +59,7 @@
|
||||
<includes>
|
||||
<include>static/</include>
|
||||
<include>index.html</include>
|
||||
<include>favicon.ico</include>
|
||||
<include>favicon.svg</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
@@ -87,13 +87,13 @@ public class ImageProcessing {
|
||||
*/
|
||||
public static void histogram(Planar<GrayU8> input) {
|
||||
int h[] = new int[256];
|
||||
Planar<GrayU8> output = input.createSameShape();
|
||||
convertColorToGray(input, output);
|
||||
Planar<GrayU8> grayInput = input.createSameShape();
|
||||
convertColorToGray(input, grayInput);
|
||||
// On remplit le tableau avec le nombre de pixels pour chaque niveau de
|
||||
// gris
|
||||
for (int y = 0; y < input.height; y++) {
|
||||
for (int x = 0; x < input.width; x++) {
|
||||
int gl = output.getBand(0).get(x, y);
|
||||
int gl = grayInput.getBand(0).get(x, y);
|
||||
h[gl]++;
|
||||
}
|
||||
}
|
||||
@@ -278,7 +278,7 @@ public class ImageProcessing {
|
||||
*
|
||||
* @param input image d'entrée
|
||||
* @param output image de sortie
|
||||
* @param size taille du filtre à appliquer
|
||||
* @param size taille du filtre à appliquer (doit être impaire)
|
||||
*/
|
||||
public static void meanFilter(Planar<GrayU8> input, Planar<GrayU8> output, int size) {
|
||||
// Vérification que la taille est impaire
|
||||
@@ -314,36 +314,6 @@ public class ImageProcessing {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* Calcule le noyau gaussien de taille demandée
|
||||
*
|
||||
* @param size taille du noyau gaussien
|
||||
* @return noyau gaussien
|
||||
*/
|
||||
public static int[][] createGaussienKernel(int size) {
|
||||
// Vérification que la taille est impaire
|
||||
if (size % 2 == 0 || size < 0) {
|
||||
throw new IllegalArgumentException("La taille doit être impaire et positive");
|
||||
}
|
||||
double[][] kernel = new double[size][size];
|
||||
double sigma = 4 / 3;
|
||||
double sum = 0.0; // For accumulating the kernel values
|
||||
for (int x = 0; x < size; ++x)
|
||||
for (int y = 0; y < size; ++y) {
|
||||
kernel[x][y] = 1 / (2 * Math.PI * sigma * sigma) * Math.exp(-(x * x + y * y) / (2 * sigma * sigma));
|
||||
|
||||
}
|
||||
|
||||
// Normalize the kernel
|
||||
int[][] kernelk = new int[size][size];
|
||||
for (int x = 0; x < size; ++x)
|
||||
for (int y = 0; y < size; ++y)
|
||||
kernelk[x][y] = (int) (kernel[x][y] / sum);
|
||||
|
||||
return kernelk;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Effectue une convolution sur une image avec le noyau
|
||||
@@ -354,9 +324,8 @@ public class ImageProcessing {
|
||||
* @param kernel Le noyau de convolution à utiliser.
|
||||
*/
|
||||
public static void gaussienFilter(Planar<GrayU8> input, Planar<GrayU8> output,
|
||||
int size) {
|
||||
int[][] kernel = { { 1, 2, 3, 2, 1 }, { 2, 6, 8, 6, 2 }, { 3, 8, 10, 8, 3 }, { 2, 6, 8, 6, 2 },
|
||||
{ 1, 2, 3, 2, 1 } };
|
||||
int[][] kernel) {
|
||||
int size = kernel.length;
|
||||
int half = size / 2;
|
||||
int totalCoefs = 0;
|
||||
// Calcul du nombre total de coefficients dans le noyau
|
||||
|
||||
@@ -5,6 +5,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@@ -38,8 +39,24 @@ public class ImageControllerTests {
|
||||
@Test
|
||||
@Order(1)
|
||||
public void getImageListShouldReturnSuccess() throws Exception {
|
||||
ReflectionTestUtils.setField(Image.class, "count", Long.valueOf(0));
|
||||
ImageDao imageDao = new ImageDao();
|
||||
var images = imageDao.retrieveAll();
|
||||
this.mockMvc.perform(get("/images")).andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(print())
|
||||
.andExpect(jsonPath("$[0].id").value(String.valueOf(images.get(0).getId())))
|
||||
.andExpect(jsonPath("$[0].name").value(images.get(0).getName()))
|
||||
.andExpect(jsonPath("$[0].size").value(images.get(0).getSize()))
|
||||
.andExpect(jsonPath("$[0].type").value(images.get(0).getMediaType().toString()))
|
||||
.andExpect(jsonPath("$[2].id").value(String.valueOf(images.get(2).getId())))
|
||||
.andExpect(jsonPath("$[2].name").value(images.get(2).getName()))
|
||||
.andExpect(jsonPath("$[2].size").value(images.get(2).getSize()))
|
||||
.andExpect(jsonPath("$[2].type").value(images.get(2).getMediaType().toString()))
|
||||
.andExpect(jsonPath("$[4].id").value(String.valueOf(images.get(4).getId())))
|
||||
.andExpect(jsonPath("$[4].name").value(images.get(4).getName()))
|
||||
.andExpect(jsonPath("$[4].size").value(images.get(4).getSize()))
|
||||
.andExpect(jsonPath("$[4].type").value(images.get(4).getMediaType().toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user