MATLAB: How to randomly select n number of pixels from an image whose value is one How to randomly select n number of pixels from an image whose value is one ? Best Answer ind = find(I == 1); r = randperm(numel(ind)); r = r(1:n); Related SolutionsMATLAB: How to randomly select n number of pixels from an image whose value is one and change those pixels value to zero ind = find(I == 1); r = randperm(numel(ind)); r = r(1:n); I(ind) = 0; MATLAB: Select randomly “N” rows of a matrix try:N=2; % no. of rows neededM=rand(5) % generate a 5x5 matrix randomc=randperm(length(M),N) B=M(c,:) % output matrix Related QuestionHow to crop image selected area
Best Answer