How to use blockproc by location?
Mostrar comentarios más antiguos
Hy all, is blockproc could be used to block by location(x,y) that i give? Ex: I have image with 64x64 pixels, and i want to turn white every pixel around location point(x,y), let's say i want to change [3 3] around the point. could blockproc do it? or there any suggestion for me?
Thanks, :).
Respuesta aceptada
Más respuestas (2)
KALYAN ACHARJYA
el 16 de Jun. de 2019
Editada: KALYAN ACHARJYA
el 16 de Jun. de 2019
#Edited
Considering Input Image is Gray, let say image1 and location of pixel is x,y
image1(y-1:y+1,x-1:x+1)=255;
5 comentarios
Image Analyst
el 16 de Jun. de 2019
Correction, since images are accessed as image1(row, column), not image1(x, y):
image1(y-1:y+1, x-1:x+1) = 255;
KALYAN ACHARJYA
el 16 de Jun. de 2019
Editada: KALYAN ACHARJYA
el 16 de Jun. de 2019
Thank you @ImageAnalyst, Let say I have image size of 20x25, that menas it has 20 rows 25 colm
%
Again let say I want to make white pixel around the spatial coordinats (11,15), neighbour pixels only (3x3) ...............................................................................................^(r,c)
image(11-1:11+1,15-1:15+1) = 255;
Where I am doing wrong? Gratitude!

Walter Roberson
el 16 de Jun. de 2019
spatial coordinates (11,15) would typically be a statement of (x, y) coordinates, which would be column 11 row 15, leading to image1(15-1:15+1,11-1:11+1) = 255;
KALYAN ACHARJYA
el 16 de Jun. de 2019
Thank you @Walter @ImageAnalyst
Elder Winter
el 20 de Jun. de 2019
Walter Roberson
el 16 de Jun. de 2019
Editada: Walter Roberson
el 16 de Jun. de 2019
blockproc is a waste for this kind of task, but it can be done. You would specify a blocksize of 3 x 3 and an overlap of [1 1], and then in the block_struct that is passed to your function, you would test for location == [y-1, x-1] and make the change in that case and otherwise return the input.
But there is just no point to this as you can go directly to that block.
YourImage(y-1:y+1, x-1:x+1, :) = 255; %assuming uint8
If you do not want to touch the center pixel then
YourImage(y-1:y+1, [x-1 x+1], :) = 255;
YourImage([y-1 y+1], x, :) = 255;
1 comentario
Elder Winter
el 20 de Jun. de 2019
Categorías
Más información sobre Neighborhood and Block Processing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!