how can I use my function on 3*3 blocks?
Show older comments
hi I have a matrix ,I wanna use a function on 3*3 blocks. my function is: if in a block we watch just a one this block should return 1 but if all 9 elements of this block is zero this function should return 0 how can I do this in matlab?
...all the elements of this matrix is zero and one.
1 Comment
Image Analyst
on 9 Apr 2015
Give examples of the 3x3 blocks that return 1 and 0. I especially don't understand the grammar of "if in a block we watch just a one this block should return 1". Exactly what returns a 1? Does this:
[.2 .3 .4
.3. .5 .6
.6 .7 .9]
Does this?
[0 0 1
0 0 0
0 0 0]
Accepted Answer
More Answers (1)
Roger Stafford
on 10 Apr 2015
m = M(a:a+2,b:b+2); % This is your "block"
t = +any(m(:)~=0); % This is the returned value
Categories
Find more on Blocked Images in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!