필터 지우기
필터 지우기

Selecting all pixels except one pixel

조회 수: 2 (최근 30일)
med-sweng
med-sweng 2013년 5월 23일
Say that we have a 3x3 matrix. If we type x(:), this will select all the elements in the matrix, right?
How can we select all the elecments except element x(2,2)? What should we type in this case?
Thanks.
  댓글 수: 1
Image Analyst
Image Analyst 2013년 5월 23일
What are you doing? Because if you're doing something like linear filtering via convolution or morphological filtering, you would do this be proper selection of the kernel.

댓글을 달려면 로그인하십시오.

채택된 답변

Iain
Iain 2013년 5월 23일
You need to use linear or logical indexing to do that. In this case, linear would be easier:
The indices for a 3x3 are:
[1 4 7;
2 5 8;
3 6 9];
So you can access it via x([1:(1 before the one you don't want) (1 after the one you don't want:end]), so for your example:
x([1:4 6:9]);
  댓글 수: 2
Iain
Iain 2013년 5월 23일
Logical indexing would use something more like x(x > 5), and it would select only those elements greater than 5.
Iain
Iain 2013년 5월 23일
I should also say that x .* (x>5) also "selects" the bits of x that are greater than 5, but it keeps the shape of x.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by