How to Add Image Classes?

1 visualización (últimos 30 días)
Qvna Lhyvnav
Qvna Lhyvnav el 18 de Mayo de 2019
Comentada: Qvna Lhyvnav el 18 de Mayo de 2019
I want to classify my image files into 4 classes, but I only get 0 and 1 with this code:
Target_Data = ones(1,Total_Images);
Target_Data(1:Total_Images/4) = 0;
How to add the other classes? Thank you.

Respuesta aceptada

Walter Roberson
Walter Roberson el 18 de Mayo de 2019
Target_Data = repmat((1:4).', Total_Images/4, 1);
  7 comentarios
Walter Roberson
Walter Roberson el 18 de Mayo de 2019
Target_Data = repelem(1:4, Total_Images/4);
Qvna Lhyvnav
Qvna Lhyvnav el 18 de Mayo de 2019
Done. Thank you for your help!

Iniciar sesión para comentar.

Más respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 18 de Mayo de 2019
Editada: KALYAN ACHARJYA el 18 de Mayo de 2019
May be you are confusing with logical indexing, there is nothing related to classification of images
lets say Total_Images=8, that menas Target_Data= ones(1,8)
>> Target_Data=ones(1,Total_Images)
Target_Data =
1 1 1 1 1 1 1 1
in next line Total_Images/4=2, so the next line is Target_Data(1:2)=0
>> Target_Data(1:Total_Images/4)=0
Target_Data =
0 0 1 1 1 1 1 1
It is checking the 1 D array elements from 1 to 2 (Target_Data(1:2)) equal to zero or not, its false logic, therefore it is zero,
There for 1st and 2nd elements are 0 and rest are same as initial Taret__Data.
If you do following one, lets check all Target_Data elemets, wheather 0 or not, you may get all zero in resultant target elements.
>> Target_Data(1:8)=0
Target_Data =
0 0 0 0 0 0 0 0
I didnot find any clue to classes images based on these two statements, if you can, as you now undestand the code, do modification accordingly.
  1 comentario
Qvna Lhyvnav
Qvna Lhyvnav el 18 de Mayo de 2019
Thank you for your reply. I understand, but I want to make four classes (60 files with each 15 files has different values). This code works for two classes.

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing and Computer Vision en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by