From: Walter Roberson on 28 Mar 2010 22:00 Sami Oueslati wrote: > My grayscale image has a black grid (vertical and horizontal black > lines) and I want to treat every rectangular region composed by these > lines. > > How to do it please?? I note from your posted image that there is extra information around the edge (which you presumably want to automatically ignore); I also see that although the grid lines themselves do not "outline" the area of interest, that there is a thinner black border at the edge of the area of interest; I also note that the grid lines are not regularly spaced, so each one will have to be detected individually. And to answer a couple of questions I had mentally before I saw the image: Yes, the grid lines do appear to be darker than anything else on the image, and No, the grid lines are never "interrupted" by the object. The above are not intended to be any kind of solution: just notes for others so that they have a better idea of what problem is being faced.
From: Sami Oueslati on 28 Mar 2010 22:12 noticing also that I have the coordinates of the lines
From: Walter Roberson on 28 Mar 2010 22:40 Sami Oueslati wrote: > noticing also that I have the coordinates of the lines That could help a lot. Do you also know the boundary of the box around the image? Certainly boxes and lines can be detected, but if you don't have to then it saves a lot of trouble. I note that the lines are more than one pixel thick. When you are processing, should only the part strictly inside the lines be considered, or do you want to include some or all of the grid as well? The coordinates you have for the lines -- is that for the center of the lines, or is that for particular edges (e.g., left edge or top edge) of the line? Subsectioning into blocks relatively easy if you have coordinates and you know exactly how the coordinates relate to the lines.
From: Sami Oueslati on 28 Mar 2010 23:00 the lines are just one pixel thick, for example the coordinates of vetical lines are: [17 37 58 82 100 120 145] and for horizontal are: [24 47 72 93 116 138] I need strictly parts inside, every rectangular region without lines to measure the mean gray level of each one
From: Sean on 28 Mar 2010 23:08
"Sami Oueslati" <Samyw69(a)yahoo.fr> wrote in message <hop29l$jbh$1(a)fred.mathworks.com>... > noticing also that I have the coordinates of the lines If you have the coordinates that makes this much easier: >>I = imread('image avec grille.jpg'); >>I = rgb2gray(I); >>Imap = ones(size(I)) %make true map >>Imap(row_lines,:) = 0; %set grid lines to false >>Imap(:,col_lines) = 0; >>Imap = padarray(Imap,[1 1],1); %Pad your map with true so that the biggest object will include everything on the border >>cc = bwconncomp(Imap) %Connected Components Analysis >>I = padarray(I,[1 1], 0); %Make I the same size Now do your operations on I(cc.PixelIdxList{}); i.e. if you want the mean of the 15th box mean(I(cc.PixelIdxList{15})) Notes: -object one will be the border area outside of the grid. -you can use bwlabel(Imap) to see which boxes are which. -you can use cellfun or regionprops to do the operations on all boxes at once. |