vendredi 9 mars 2018

How to write an if else statement in matrix matlab

I am trying to read an image and get the x,y and pixel coordinates. It is an RGB image which has a size (282,282,3). However I get pixel coordinates matrix of (282*3, 282, pixel values). Further, though the if else condition is working for normal given values, in this code, it is not working. Can anyone help me find where I went wrong?

clear all clc

A = double(imread('F:\02.jpg'));
size(A)
[length, width] = size(A);
[x, y] = meshgrid(1:width, 1:length);
z(:) = A(:)/255;
if(z >=0.50000)
z =1;
elseif(z <0.50000)
z=0;
end
Z = z(:)

Aucun commentaire:

Enregistrer un commentaire