How to calculate the number of grid on the image whose having the outline of the image
Show older comments

This is my input image, and my code is this ->
img = imread('tanjore3.png');
img(10:10:end,:,:) = 0;
img(:,10:10:end,:) = 0;
imshow(img);
i just place a grid on the image
now the partial output of this is shown below. My question is how to calculate the number of grid whose having the outline of the image ?
My output should be Example : OUTPUT=25 grids

7 Comments
Walter Roberson
on 2 Sep 2015
It would be easier if you were to be able to specify the grid spacing as a number of pixels, instead of having to figure it out from the graph.
SWAMINATHAN
on 3 Sep 2015
Image Analyst
on 9 Sep 2015
How are you numbering your grid? Do you want grid row and grid column, starting from the upper left? Or lower left?
SWAMINATHAN
on 10 Sep 2015
Walter Roberson
on 10 Sep 2015
My blockproc() should do that, unless I made a typing mistake.
Image Analyst
on 14 Sep 2015
Don't be silly. OF COURSE the starting point of the grid lines has an effect. Just think about it. Just imagine that the whole grid was lowered a few pixels. Then the dip in the 8th grid column would show up in only one grid row, not two.
SWAMINATHAN
on 15 Sep 2015
Accepted Answer
More Answers (1)
Walter Roberson
on 4 Sep 2015
Edited: Walter Roberson
on 4 Sep 2015
Let N be the interval between boundaries, in pixels. Then
black_line_detected = blockproc(YourImage, [N, N], @(block) ~all(block.data), 'PadMethod', 1);
detect_count = sum(black_line_detected(:));
10 Comments
SWAMINATHAN
on 9 Sep 2015
Edited: SWAMINATHAN
on 9 Sep 2015
Walter Roberson
on 9 Sep 2015
YourImage = imread('tanjore3.png');
N = 25;
black_line_detected = blockproc(YourImage, [N, N], @(block) ~all(block.data), 'PadMethod', 1);
detect_count = sum(black_line_detected(:));
You asked for the number of grid areas, and detect_count is that number.
SWAMINATHAN
on 14 Sep 2015
Edited: SWAMINATHAN
on 14 Sep 2015
SWAMINATHAN
on 14 Sep 2015
Image Analyst
on 14 Sep 2015
If this is an outline of a temple that you got by calling bwperim() or bwboundaries(), then you should have all the (x,y) coordinates of the image. That would make it SO much easier than dealing with an image that had black gridlines burned into it. Please attach a mat file with the list of outline coordinates. I'm sure you definitely have this.
SWAMINATHAN
on 15 Sep 2015
Edited: Walter Roberson
on 15 Sep 2015
Image Analyst
on 15 Sep 2015
What is your grid spacing in pixels, and where does the first grid line start? For example, grid spacing is 50 pixels and the first grid line is at 1 so that grid #1 is at 1-50, grid #2 is 51-100, etc. Or does it start around 25 like you showed so grid #1 is 1-25, grid 2 is 26-75, grid 3 is 76-125, etc.?
Walter Roberson
on 16 Sep 2015
The grid spacing is variable and it starts anywhere consistent. The poster is doing a kind feature analysis, refining the grid more each time and wanting to know the count at each step.
SWAMINATHAN
on 21 Sep 2015
SWAMINATHAN
on 21 Sep 2015
Edited: Walter Roberson
on 21 Sep 2015
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

