Bonjour,
Je veux faire la différence entre deux images pour voir des taches. Mais pour utiliser la fonction K=difference(A, B); j'ai dois avoir deux images de la même taille, ce qui nest pas le cas. J'ai écrit une fonction pour ajouter des lignes noires en bas de la matrice et des colonnes noires à droite de celle-ci pour qu'elle aient la même taille. Cependant mon programme ne fonctionne pas et je ne trouve pas mon erreur.
L'erreur affichée par MATLAB est:
Error using vertcat CAT arguments dimensions are not consistent. Error in sizeMatrix (line 13) fixed_row=[fixed ; New];
Est-ce que quelqu'un sait comment résoudre ce problème ? Merci d'avance.
Ma fonction est:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 function [ A,B ] = sizeMatrix( I,J ) final_moving=J; fixed=I; rowMax_fixed=size(fixed,1); colMax_fixed=size(fixed,2); rowMax_final_moving=size(final_moving,1); colMax_final_moving=size(final_moving,2); if rowMax_final_moving > rowMax_fixed New=zeros(rowMax_final_moving-rowMax_fixed, colMax_fixed); fixed_row=[fixed ; New]; colMax_fixed_row=size(fixed_row,2); rowMax_fixed_row=size(fixed_row,1); if colMax_final_moving > colMax_fixed_row NewB=zeros(rowMax_fixed_row, colMax_final_moving-colMax_fixed_row); fixed_row_col=[fixed_row , NewB]; A=fixed_row_col; B=final_moving; else NewB=zeros(rowMax_final_moving, colMax_fixed_row-colMax_final_moving); final_moving_col=[final_moving , NewB]; A=fixed_row; B=final_moving_col; end elseif rowMax_final_moving == rowMax_fixed && colMax_final_moving == colMax_fixed A=fixed; B=final_moving; else New=zeros(rowMax_fixed-rowMax_final_moving, colMax_final_moving); final_moving_row=[final_moving; New]; colMax_final_moving_row=size(final_moving_row,2); rowMax_final_moving_row=size(final_moving_row,1); if colMax_final_moving_row > colMax_fixed NewB=zeros(rowMax_fixed, colMax_final_moving_row-colMax_fixed); fixed_col=[fixed , NewB]; A=fixed_col; B=final_moving_row; else NewB=zeros(rowMax_final_moving_row, colMax_fixed-colMax_final_moving_row); final_moving_row_col=[final_moving_row , NewB]; A=fixed; B=final_moving_row_col; end end A; B; end
Partager