Eliminating element if a vector
이전 댓글 표시
Suppose I have a vector of 6 elements i.e. [4 5 6 5 4 8].I want to write a code that should run across the column and when it encounters the value of 6, all the values should be made equal to zero regardless whether they are greater then 6 or smaller than it. The output should be like this [4 5 6 0 0 0]. I want to use this technique in image processing to make the values of the pixels below or above a certain threshold equal to zero when the threshold is detected.This process is repeated over all the columns in an image.
채택된 답변
추가 답변 (1개)
Andrei Bobrov
2016년 1월 20일
a = [4 5 6 5 4 8];
ii = find(a == 6,1,'first')
out = a;
out(ii+1:end)=0
카테고리
도움말 센터 및 File Exchange에서 Image Thresholding에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!