Finding value of a matrix
이전 댓글 표시
I have a 3x3 matrix, for example:
d=rand(3,3)
Now i want to implement the equation
V=1/2(d(q4,q5)+d(q5,q6))
where q5 is the centre pixel
q4,46 are neighbouring pixels
for example
d= q1 q2 q3
q4 q5 q6
q7 q8 q9
please assist
댓글 수: 1
Walter Roberson
2012년 12월 19일
q4 and q5 and so on are values of those pixels?
채택된 답변
추가 답변 (2개)
Muruganandham Subramanian
2012년 12월 19일
편집: Muruganandham Subramanian
2012년 12월 19일
d=ones(3);
V=1/2*(d(d(2,2),d(2,2))+d(d(2,2),d(2,3)))
but, If you're using rand(), d(2,2),etc.. can't be accessible, if not using ceil() or floor()..Is this you want?
댓글 수: 7
FIR
2012년 12월 19일
Muruganandham Subramanian
2012년 12월 19일
have you tried this?
d=ones(3);
V=1/2*(d(d(2,2),d(2,2))+d(d(2,2),d(2,3)))
FIR
2012년 12월 19일
Muruganandham Subramanian
2012년 12월 19일
편집: Muruganandham Subramanian
2012년 12월 19일
@FIR, thanks for corrected error.. i.e. V=1/2*(d(d(2,1),d(2,2))+d(d(2,2),d(2,3))) only..
And I explained about this in my answer previously..
d=rand(3,3)
i.e,
d=
[q1 q2 q3
q4 q5 q6
q7 q8 q9
];
here, q5=>d(2,2)..right? but, If you want to get 'q5' or other data, we're indexing by d(2,2).,and that must be an whole number, shouldn't be a float.So, by using ceil(), floor() command you can get it..but when you're using rand(), it'll be float..to avoid this you can use, randi(3,3)
FIR
2012년 12월 19일
Walter Roberson
2012년 12월 19일
The confusion is between pixel locations and pixel values. You wrote the question with d(q4,q5) which based on the way you wrote the question is trying to access the matrix d() at row index which is the value of the pixel you labeled q4, and column index which is the value of the pixel you labeled q5.
Muruganandham Subramanian
2012년 12월 19일
@FIR, I din't worked on images, anyway, by using imread() read your image and do the calculation
Image Analyst
2012년 12월 19일
0 개 추천
By chance do you mean just convolution with a [1 2 1]/4 kernel, where you take the average of the left pair of pixels and the right pair of pixels? If so, you'd need to extract each color plane first and then use conv2() to get the output image one color plane at a time.
카테고리
도움말 센터 및 File Exchange에서 Image Category Classification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!