Replace cell elements with a constant value?

4 visualizaciones (últimos 30 días)
RB
RB el 30 de Ag. de 2018
Comentada: Image Analyst el 4 de Sept. de 2018
Right now, I have a 4x4 cell and in each element of the cell is 25x25 values. I want to be able to go into the first cell element (1,1) and replace every single one of the 25x25 values with a constant (already defined as a variable earlier in my code). This will be within a for loop, and k has been defined as the cell element number (1 through 16 since the cell is 4x4). I am hoping to just be able to say within cell{k} replace every element with constant. And then I want to proceed and be able to replace every single cell element. Therefore, the end will be a 4x4 cell. Within each cell element, there will be 25x25 values that are all the same. Thank you for any help!

Respuestas (1)

Image Analyst
Image Analyst el 30 de Ag. de 2018
Try this (untested)
for k = 1 : numel(ca) % For every cell
% Make array of all one number.
% Then replace existing contents with this array.
ca{k}= yourConstant * ones(size(ca{k}));
end
It uses linear indexing so it should still retain the 2-D shape of the cell array, ca.
  2 comentarios
RB
RB el 4 de Sept. de 2018
I tried this code, and I get the error message: GLCM does not count pixel pairs if either of their values is NaN. And instead of replacing each 25x25 array in the 4x4 cell with the corresponding value, it is replacing every value in the cell with NaN. Do you have any idea what might be going wrong? Thanks!
Image Analyst
Image Analyst el 4 de Sept. de 2018
Attach your full code. I don't even use anything called GLCM or call graycomatrix() or graycoprops(), so it's your code, not mine that's giving the error. You did not even mention that you were using the Gray Level Cooccurrence Matrix before now.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by