how process each region of a grayscale image

  • Follow


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??
0
Reply Sami 3/29/2010 12:14:05 AM

"Sami Oueslati" <Samyw69@yahoo.fr> wrote in message <hoorcd$akt$1@fred.mathworks.com>...
> 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??

Can you show us the image?
0
Reply Sean 3/29/2010 12:59:07 AM


"Sean " <sean.dewolski@Idontwantspam.umit.maine.edu> wrote in message <hoou0r$i4n$1@fred.mathworks.com>...

> Can you show us the image?

Here's it
http://www.monsterup.com/image.php?url=upload/1269825649954.jpg
0
Reply Sami 3/29/2010 1:23:02 AM

Sami Oueslati
I didn't see an image.  All I saw was this:
"Pour enregistrer l'image, cliquez sur le bouton droit de la souris
sur l'image, puis cliquez sur enregistrer l'image sous ..."
Why don't you post to http://drop.io instead.  That's the easiest
image sharing web site by far, both for you and for us.

Also specify what you mean by "treat."
0
Reply ImageAnalyst 3/29/2010 1:31:17 AM

Hope it works now:
http://drop.io/mqlwmho#

I mean process each region separately 
0
Reply Sami 3/29/2010 1:44:04 AM

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.

0
Reply Walter 3/29/2010 2:00:44 AM

noticing also that I have the coordinates of the lines
0
Reply Sami 3/29/2010 2:12:05 AM

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.
0
Reply Walter 3/29/2010 2:40:49 AM

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
0
Reply Sami 3/29/2010 3:00:28 AM

"Sami Oueslati" <Samyw69@yahoo.fr> wrote in message <hop29l$jbh$1@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.
0
Reply Sean 3/29/2010 3:08:02 AM

On Mar 28, 9:44=A0pm, "Sami Oueslati" <Samy...@yahoo.fr> wrote:
> Hope it works now:http://drop.io/mqlwmho#
>
> I mean process each region separately

-------------------------------------------------------------
So just find the coordinates of each black bar's row and column.  Then
use those to crop out a small subregion and "treat" it as a complete
image.  What part is giving you trouble?  Finding the bar locations?
Cropping?  "Treating"?
0
Reply ImageAnalyst 3/29/2010 3:30:27 AM

Sami Oueslati wrote:
> 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

I have examined your image in fine detail, and your grid lines are NOT 
one pixel thick. You can see this clearly near 100, where there is a 
tick mark right at a grid line, and the tick mark is definitely thinner 
than the grid line. In the horizontal direction, the grid lines seem to 
be three pixels thick, and in the vertical direction, they might be four 
pixels thick (or perhaps it was just the one I was examining.)

I cropped out the part of the image from the top left corner (0, 0) to 
(140, 140), which is the where the bottom-most and right-most tick marks 
are. The cropped image was 430 pixels high and 430 pixels wide. This is 
just slightly larger than a ratio of one coordinate unit rendering as 
three pixels (which would have given 420 x 420). The slight mismatch on 
the 3:1 ratio means that you will have to somehow detect the grid lines 
instead of just calculating where they should be in the image.

I also examined the pixel values of the image and grid lines, and found 
that the grid lines are NOT a solid color. The grid lines are a range of 
colors from 0 up to about 19. However, some of the interior image pixels 
start from 12. If you select only pixels from 0 to 11 and make the rest 
white, then you will not have selected any of the interior pixels, but 
some of the grid line pixels would become white. If you set the 
threshhold any higher, so that the grid lines become solid, then you 
will also be selecting some of the real image pixels.

If you look closely at the image pixels just above the bottom border at 
the 100 mark, you will see that there is a blur for a few pixels above 
the base. This and the not-quite-regular scale-factor suggests that this 
is not a mathematically constructed image, but is instead a scan taken 
of either a photograph or a printout, and that when it was converted to 
JPEG, the qualify factor was not set sufficiently high. JPEG gets worse 
and worse about sharp edges as the quality factor is reduced. This could 
also account for _some_ of the difference in pixel values for the grid 
lines, but examining the pixels in the 12 to 19 range supports the idea 
that there really is some overlap in the pixel values of the image and 
the grid. But then again, if it is indeed a scanned image, then 
inconsistent illumination could account for some of that.
0
Reply Walter 3/29/2010 4:34:18 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <def69c42-ddf9-4260-9ddd-a9427134edeb@19g2000yqu.googlegroups.com>...
> On Mar 28, 9:44 pm, "Sami Oueslati" <Samy...@yahoo.fr> wrote:
> > Hope it works now:http://drop.io/mqlwmho#
> >
> > I mean process each region separately
> 
> -------------------------------------------------------------
> So just find the coordinates of each black bar's row and column.  Then
> use those to crop out a small subregion and "treat" it as a complete
> image.  What part is giving you trouble?  Finding the bar locations?
> Cropping?  "Treating"?

Hi, I've been absent for a long time, so I resume the subject...

Here's the image: http://drop.io/mqlwmho#

I have the coordinates of the black line that subdivide the image in subregions...My question is how to crop every subregion and how to extract the intensity of the center of each subregion???????????
0
Reply Sami 4/26/2010 11:30:24 PM

Just use regular indexing.  You can find the rows and columns of the
blanck lines dividing the subimages, can't you?  Then do
imageArray = fullSizeImage(row1:row2, col1:col2);
meanGrayValue = mean(imageArray(:));
0
Reply ImageAnalyst 4/27/2010 12:23:59 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <6bdc1204-a744-441d-a2c0-4a41e263c768@q8g2000vbm.googlegroups.com>...
> Just use regular indexing.  You can find the rows and columns of the
> blanck lines dividing the subimages, can't you?  Then do
> imageArray = fullSizeImage(row1:row2, col1:col2);
> meanGrayValue = mean(imageArray(:));

Sorry maybe you haven't understand me cause of my poor English...
I know the coordinates of the black lines (I forgot the "s"), I obtained before and constructed the grid in the image...So my intention is to separate every subregion (of the grid) formed by the black lines...and by the way determine the intensity value of the center of each subregion.
0
Reply Sami 4/27/2010 12:37:04 AM

Sami Oueslati
I understood perfectly (I believe) and I told you how to do it.
You know the starting and ending rows and columns, so just extract out each sub image and get the mean with the mean() function.  What about this makes it seem like I didn't understand?
ImageAnalyst
0
Reply Image 4/27/2010 12:57:03 AM

"Image Analyst" <imageanalyst@mailinator.com> wrote in message <hr5cov$k2s$1@fred.mathworks.com>...
> Sami Oueslati
> I understood perfectly (I believe) and I told you how to do it.
> You know the starting and ending rows and columns, so just extract out each sub image and get the mean with the mean() function.  What about this makes it seem like I didn't understand?
> ImageAnalyst
oh yes! sorry I was confused, it's because sometimes I worry about my poor english...Now I see what you mean...Thank you :)
0
Reply Sami 4/27/2010 1:09:05 AM

"Sami Oueslati" <Samyw69@yahoo.fr> wrote in message <hr5dfg$4j1$1@fred.mathworks.com>...
> "Image Analyst" <imageanalyst@mailinator.com> wrote in message <hr5cov$k2s$1@fred.mathworks.com>...
> > Sami Oueslati
> > I understood perfectly (I believe) and I told you how to do it.
> > You know the starting and ending rows and columns, so just extract out each sub image and get the mean with the mean() function.  What about this makes it seem like I didn't understand?
> > ImageAnalyst
> oh yes! sorry I was confused, it's because sometimes I worry about my poor english...Now I see what you mean...Thank you :)


Something else please,
How to put the mean values obtained, in an array where each value corresponds each subimage...I mean every subimage is replaced by the mean value obtained to finally have a representative array of the original image.... hope it's clear...
0
Reply Sami 4/27/2010 1:23:06 AM

On Apr 26, 9:09=A0pm, "Sami Oueslati" <Samy...@yahoo.fr> wrote:
> oh yes! sorry I was confused, it's because sometimes I worry about my poo=
r english...Now I see what you mean...Thank you :)
---------------------------------------------------------------------
Just in case you don't, here's a demo:
I don't know the actual rows and columns so I'm just doing it with a
subimage size of 100 by 100:

clc;    % Clear the command window.
close all;  % Close all figures (except those of imtool.)
imtool close all;  % Close all imtool figures.
clear;  % Erase all existing variables.
workspace;  % Make sure the workspace panel is showing.

% Change the current folder to the folder of this m-file.
% (The line of code below is from Brett Shoelson of The Mathworks.)
if(~isdeployed)
	cd(fileparts(which(mfilename)));
end

% Read in standard MATLAB grayscale demo image.
fullFileName =3D 'image avec grille.jpg';
grayImage =3D imread(fullFileName);
grayImage =3D rgb2gray(grayImage);
subplot(6, 4, 1);
imshow(grayImage, []);
title('Original Grayscale Image');
set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full
screen.
[rows cols numberOfColorbands] =3D size(grayImage)
counter =3D 0;
for col =3D 1:100:cols-100
    for row =3D 1:100:rows-100
        subImage =3D grayImage(row:row+99, col:col+99);
        subplot(6, 4, counter+2);
        imshow(subImage, []);
        meanGrayLevel =3D mean(subImage(:))
        counter =3D counter + 1
        caption =3D sprintf('Mean =3D %.1f', meanGrayLevel);
        title(caption);
    end
end


0
Reply ImageAnalyst 4/27/2010 1:23:31 AM

On Apr 26, 9:23=A0pm, "Sami Oueslati" <Samy...@yahoo.fr> wrote:
> How to put the mean values obtained, in an array where each value corresp=
onds each subimage...I mean every subimage is replaced by the mean value ob=
tained to finally have a representative array of the original image.... hop=
e it's clear...
----------------------------------------------------------------------
counter =3D 0;
for col =3D 1:100:cols-100
    for row =3D 1:100:rows-100
        subImage =3D grayImage(row:row+99, col:col+99);
        subplot(6, 4, counter+2);
        imshow(subImage, []);
        meanGrayLevel(counter+1) =3D mean(subImage(:))
        counter =3D counter + 1
        caption =3D sprintf('Mean =3D %.1f', meanGrayLevel(counter+1));
        title(caption);
    end
end
0
Reply ImageAnalyst 4/27/2010 1:25:18 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <6bdc1204-a744-441d-a2c0-4a41e263c768@q8g2000vbm.googlegroups.com>...
> Just use regular indexing.  You can find the rows and columns of the
> black lines dividing the subimages, can't you?  Then do
> imageArray = fullSizeImage(row1:row2, col1:col2);
> meanGrayValue = mean(imageArray(:));
--------------------------------------------------------

If I have the coordinates of the horizontal black lines in the vector "H".
If I have the coordinates of the vertical black lines in the vector "V".

supposing:
X : original image
Y1...Yn : subimages

How to make an iterative program to determine the subimages automatically?
Is it on this way???

Y1 = X (1:H(1), 1:V(1));
Y2 = X (1:H(1), V(1):V(2));
....
Yk = X (H(1):H(2), 1:V(1)); How to pass from 1:H(1) to H(1):H(2)??
....
Yn = X(H(n):size(X,1), V((n):size(X,2));

Hope you see what I mean..
0
Reply Sami 4/27/2010 3:00:09 AM

Just do what I did above except the for loops will look like:
for col = H
  for row = V
       % extract subimage....
  end
end
0
Reply ImageAnalyst 4/27/2010 10:14:16 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <7c9fe192-effc-48c8-8de5-ccff825788bf@x3g2000yqd.googlegroups.com>...
> Just do what I did above except the for loops will look like:
> for col = H
>   for row = V
>        % extract subimage....
>   end
> end
-------------------------------------------------------------------------------------
Hi ImageAnalyst,
I've been trying to solve the problem following what you wrote but I didn't arrive to good results. Please, review what I want to do.

I show you the image again 
http://drop.io/mqlwmho#

I remember you that I must calculate the gray level of the center of each rectangular region formed by the grid (the vector "H" contains the coordinates of the horizontal black lines. the vector "V" contains the coordinates of the vertical black lines).

Then I want to regroup the gray levels obtained in a matrix that has the size (Number of regions in the row direction x number if regions in column direction).

My problem is the starting of the loops:
for ii=1:H:size(grayImage,1)
     for jj=1:V:size(grayImage,2)
          
But it doesn't work...
Hope you'll help me.
0
Reply Sami 5/6/2010 5:36:06 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <7c9fe192-effc-48c8-8de5-ccff825788bf@x3g2000yqd.googlegroups.com>...
> Just do what I did above except the for loops will look like:
> for col = H
>   for row = V
>        % extract subimage....
>   end
> end
-----------------------------------------------------------------------------
Hi ImageAnalyst,

Please help me to solve this problem... I don't know which indexes I must use for the loops
http://drop.io/mqlwmho#
I need to extract the gray values of the centers of each region and put the results on a matrix that has the dimensions (regions on vertical axis X regions on horizontal axis)

I must achieve my work in two weeks...so I haven't too much time....
Please, You are my last chance...
0
Reply Sami 5/9/2010 1:55:11 AM

On May 8, 9:55=A0pm, "Sami Oueslati" <Samy...@yahoo.fr> wrote:
> Hi ImageAnalyst,
>
> Please help me to solve this problem... I don't know which indexes I must=
 use for the loopshttp://drop.io/mqlwmho#
> I need to extract the gray values of the centers of each region and put t=
he results on a matrix that has the dimensions (regions on vertical axis X =
regions on horizontal axis)
>
> I must achieve my work in two weeks...so I haven't too much time....
> Please, You are my last chance...
---------------------------------------------------------------------------=
-----------------
Why don't you post the original image?  All those annotation and tick
marks are really complicating things.  Plus the jpegging is blurring
the lines.  Post the original, uncompressed image that you put into
the figure.  It should be a png, tif, or bmp format image.  The figure
itself is no good - we don't want the title, and all the numbers, tick
marks, etc.

Here's a hint:

clc;    % Clear the command window.
close all;  % Close all figures (except those of imtool.)
imtool close all;  % Close all imtool figures.
clear;  % Erase all existing variables.
workspace;  % Make sure the workspace panel is showing.
fontSize =3D 20;

% Change the current folder to the folder of this m-file.
% (The line of code below is from Brett Shoelson of The Mathworks.)
if(~isdeployed)
	cd(fileparts(which(mfilename)));
end

% Read in color jpg demo image.
folder =3D 'C:\Documents and Settings\user\My Documents\Temporary
stuff';
fullFileName =3D fullfile(folder, 'grille.jpg');
rgbImage =3D imread(fullFileName);
grayImage =3D rgb2gray(rgbImage);
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image');
set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full
screen.

binaryImage =3D grayImage < 10;
subplot(2, 2, 2);
imshow(binaryImage, []);
title('Binary Image');

verticalProfile =3D sum(grayImage, 2);
subplot(2, 2, 3);
plot(verticalProfile);
title('Vertical Profile');

horizontalProfile =3D sum(grayImage, 1);
subplot(2, 2, 4);
plot(horizontalProfile);
title('Horizontal Profile');


0
Reply ImageAnalyst 5/9/2010 2:25:34 AM

Thanks for accepting to help me,
Here's the program's code. Some variables are in French..I translated a big part of it in English. Hope it's clear in general
I put the original bitmap image to test http://drop.io/mqlwmho# 
-------------------------------------------------------------------------------------------------------
clc;
close all;
clear all;

%----------------------read and show the image-----------------
I=input('Choose an image:'); 
I = imread(I);
I = rgb2gray(I);
I = medfilt2(I);
h = ones(3,3);
ImageGris = imerode(I,h);
subplot(3,2, 1);
imshow(ImageGris);
title('Image prétraitée');
axis on;

%----------------------Binarize Image---------------
ImageBinarisee = ImageGris > 85;
ImageBinarisee=~ImageBinarisee;
ImageBinarisee = bwareaopen(ImageBinarisee,30);
subplot(3,2, 2);
imshow(ImageBinarisee, []);
title('Image binarisée');
axis on;

%----------------------Vertical Bands---------------
[lign col Ncb] = size(ImageGris);
ImageBinarisee(1,:)=0;
ImageBinarisee(:,1)=0;
ImageBinarisee(:,size(ImageBinarisee,2))=0;
ImageBinarisee(size(ImageBinarisee,1),:)=0;
ImageBandes = uint8(127 * ones(lign, col));
ImageBandes(:, max(ImageBinarisee,[],1) > 0 ) = 255;
subplot(3,2, 3);
imshow(ImageBandes);
title('Bandes verticales');
axis on;

%----------------------Vertical Midlines------------
VProfil = (max(ImageBinarisee) == 1);
BandeBord = diff(VProfil);% localize start and end of band
BandeDebut = find(BandeBord == 1);% localize start of band
BandeFin = find(BandeBord == -1);% Localize end of band
LigneV = round((BandeDebut + BandeFin) / 2);
ImageBinarisee1 = ImageBandes; % 
ImageBinarisee1(:, LigneV) = 0; % Draw midlines.

subplot(3,2, 4);
imshow(ImageBinarisee1, []);
title('Bandes verticales coupées au milieu');
axis on;
     
%--------------------Horizontal Bands--------------------------
ImageBandes1 = uint8(127 * ones(lign, col));
ImageBandes1(max(ImageBinarisee,[],2) > 0,:) = 255;
subplot(3,2, 5);
imshow(ImageBandes1);
title('Bandes horizontales');
axis on;
    
%--------------------Horizontal Midlines--------------------
HProfil = (max(ImageBinarisee,[],2) == 1);
HProfil=HProfil';
BandeBord1 = diff(HProfil,[],2);% Localiza start and end of bands
BandeDebut1 = find(BandeBord1 == 1);% localize start of band
BandeFin1 = find(BandeBord1 == -1);% Localize end of band
LigneH = round((BandeDebut1 + BandeFin1) / 2);
ImageBinarisee2 = ImageBandes1; 
ImageBinarisee2(LigneH,:) = 0; % Draw midlines.

subplot(3,2, 6);
imshow(ImageBinarisee2, []);
title('Bandes horizontales coupées au milieu');
axis on;

%---------------Image with grid-----------------------------------
ImageGrille = ImageGris;
ImageGrille(:,LigneV) = 0; %tracer les lignes verticales
ImageGrille(LigneH,:) = 0; %tracer les lignes horizontales 

figure, imshow(ImageGrille);
title('Image avec grille');
axis on;

%------------Grayscale values of center of each region------- %INCOMPLETE

for x = 1:LigneH:lign
  for y = 1:LigneV:col
      CaseGrille = ImageGris(x:LigneH,y:LigneV);
  end
  
end
0
Reply Sami 5/9/2010 3:07:04 AM

On May 8, 11:07=A0pm, "Sami Oueslati" <Samy...@yahoo.fr> wrote:
> Thanks for accepting to help me,
> Here's the program's code. Some variables are in French..I translated a b=
ig part of it in English. Hope it's clear in general
> I put the original bitmap image to test http://drop.io/mqlwmho#
> -------------------------------------------------------------------------=
------------------------------

Your original image does not have any black grille over it so how can
you find it?

Plus your original image seems to be overexposed.
I've been thinking that you have an image that you're starting with
that has black vertical lines and black horizontal lines over it, but
now you post an original image with no such lines.
Apparently the lines were drawn afterwards.  If you drew them then you
know where you drew them.
Why don't you just forget about the grille (black lines), and explain
what you want to do with the original (no grille) image?
0
Reply ImageAnalyst 5/9/2010 3:18:32 AM

> Your original image does not have any black grille over it so how can
> you find it?
> 
> Plus your original image seems to be overexposed.
> I've been thinking that you have an image that you're starting with
> that has black vertical lines and black horizontal lines over it, but
> now you post an original image with no such lines.
> Apparently the lines were drawn afterwards.  If you drew them then you
> know where you drew them.
> Why don't you just forget about the grille (black lines), and explain
> what you want to do with the original (no grille) image?
----------------------------------------------------------------------------------------------

The code below processes the original image that I gave you and convert it in an image with grid..to obtain it, you have to run the code that tells you to choose an image and you just have to write '3an.bmp'

After that I want to extract the gray level values of the centers of the rectangular region formed by the grid (the black lines are saved in the variables LigneH and LigneV)
Then I put the results in another matrix that has the size (regions in vertical direction x regions in horizontal direction: for my image in this case size=4x8 but it can be another size: I have a lot of other images and the size change that's why I must run a code that processes any image)

Hope you understand what I mean to do
0
Reply Sami 5/9/2010 3:43:05 AM

You need to replace that last part with something like this:

figure, imshow(ImageGrille);
title('Image avec grille');
axis on;
set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full
screen.

%------------Grayscale values of center of each region-------
%INCOMPLETE
%
% for x = 1:LigneH:lign
%   for y = 1:LigneV:col
%       CaseGrille = ImageGris(x:LigneH,y:LigneV);
%   end
% end
% Add the first and last columns.
LigneH = [1 LigneH col]
% Add the first and last rows.
LigneV = [1 LigneV lign]
lastTileX = length(LigneH)
lastTileY = length(LigneV)
figure;
set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full
screen.

counter = 0;
for tileX = 1 : lastTileX-1
    column1 = LigneH(tileX)
    column2 = LigneH(tileX+1)
    if column1 > col || column2 > col
        % Skip bad ones.
        continue;
    end
    for tileY = 1 : lastTileY-1
        row1 = LigneV(tileY)
        row2 = LigneV(tileY+1)
        if row1 > lign || row2 > lign
            % Skip bad ones.
            continue;
        end
        subImage = grayImage(row1:row2, column1:column2);
        subplot(lastTileY, lastTileX, counter+2);
        imshow(subImage, []);
        meanGrayLevel = mean(subImage(:))
        counter = counter + 1
        caption = sprintf('Mean = %.1f', meanGrayLevel);
        title(caption);
    end
end



But it appears that your LignV is messed up because it goes past the
last row of your image.

0
Reply ImageAnalyst 5/9/2010 1:19:33 PM

> But it appears that your LignV is messed up because it goes past the
> last row of your image.
---------------------------------------------------------------------------------------------------
Hi, thanks it looks good.

But LigneV is not messed up, LigneV represent the vertical black lines and LigneH the horizontal ones..you wrote ligneV = [1 LigneV lign] when the correct statement it's ligneV = [1 LigneV col] and for ligneH = [1 LigneH col] and the correst statement it's LigneH = [1 LigneH lign].

Maybe you confused between rows (lign) and columns (col)... May I change another statements? because in the figure the regions don't seem to be the ones of my image! the size it's not the same, normally I must have 5x8 and there's only 5x6 and the first column still moved. I think you've taken the mean values of the regions and in fact I need the gray value of the center of the region..And finally how to collect the gray values in a matrix 5x8??

Thanks a lot really.
0
Reply Sami 5/9/2010 4:18:03 PM

Your image is 284 rows or lines by 376 columns.
With your code (before I tacked on the first and end elements), I get
LigneH =
    45   133   210   268

LigneV =
    17    67   122   176   225   281   342

Now, ligne (the number of lines (rows)) is only 284, so 342 is beyond
that, hence I had to skip those tiles.

It could be that you or me reversed meanings, because you have
ImageGrille(:,LigneV) = 0; %tracer les lignes verticales
ImageGrille(LigneH,:) = 0; %tracer les lignes horizontales
Usually I have V mean "Vertical" and that means in the row direction,
and H means "horizontal" which is in the columns direction.  However
you have them in the opposite position, V in the columns position, and
H in the rows position.  Maybe you use that definition because the
indexes in the H direction apply for every row in the image and hence
appear as vertical lines even though LigneV actually indicates column
numbers.  Anyway, if your H and V are different than my definitions,
if it still works, then fine.

To get a smaller mean, just adjust row1, row2, column1, and column2 in
the loop to get the most central 5x8 chunk of the tile.  This is very,
very easy to do and I'm sure you can figure it out.
0
Reply ImageAnalyst 5/9/2010 5:22:01 PM

> To get a smaller mean, just adjust row1, row2, column1, and column2 in
> the loop to get the most central 5x8 chunk of the tile.  This is very,
> very easy to do and I'm sure you can figure it out.
----------------------------------------------------------------------------------------------
I meant the center must be 1x1, I've changed the statement like this but it doesn't work:

subImage = ImageGris(row1+(row1+row2)/2:row2-(row1+row2)/2, column1+(column1+column2)/2:column2-(column1+column2)/2);

and last thing how to collect the meanGrayLevels of each center (1x1) in a Matrix (5x8: there's 40 regions) with the same order as the disposition of my regions in the image with grid?
0
Reply Sami 5/9/2010 7:06:03 PM

Come on now, this is very, very easy to do - you don't need me to do
that.

The pixel value at some x,y (which is at the center of your subImage
tile) is simply
x = int32((column1 + column2)/2);
y = int32((row1 + row2)/2);
pixelValue = ImageGris(x,y);

then stuff it in an array
center_GrayLevel_Values(counter) = pixelvalues;

I mean, I know you're a beginner but this is really trivial stuff -
not sure where your confusion lies....
0
Reply ImageAnalyst 5/9/2010 7:37:47 PM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <084724db-5d78-41f8-bd94-f8ddebbbe7d5@u7g2000vbq.googlegroups.com>...
> Come on now, this is very, very easy to do - you don't need me to do
> that.
> 
> The pixel value at some x,y (which is at the center of your subImage
> tile) is simply
> x = int32((column1 + column2)/2);
> y = int32((row1 + row2)/2);
> pixelValue = ImageGris(x,y);
> 
> then stuff it in an array
> center_GrayLevel_Values(counter) = pixelValue;
> 
> I mean, I know you're a beginner but this is really trivial stuff -
> not sure where your confusion lies....
------------------------------------------------------------------------------------------
Sorry, I know...It's easy for you but for me It's complicated because I'm not used in programming...Hoped that I don't ask for help but due to the short time that I have to finish my work..I feel like incapable to do it fastly..

Last thing and you will not hear about me no more :))...How I put the values obtained in a matrix that has the size (nb of regions in x direction X nb of regions in y direction)??

a thousand thanks!!!

  
0
Reply Sami 5/9/2010 10:30:22 PM

On May 9, 6:30=A0pm, "Sami Oueslati" <Samy...@yahoo.fr> wrote:
How I put the values obtained in a matrix that has the size (nb of
regions in x direction X nb of regions in y direction)??
----------------------------------------------------------------------
I don't understand the question.  Can you supply an example?

Do you mean
centralValues(tileY, tileX) =3D ImageGris(x,y);

??????
0
Reply Tombo 5/10/2010 12:16:07 AM

Sami Oueslati:
I'm not sure exactly what you're after.....I guess I don't quite
understand the grammar.
0
Reply ImageAnalyst 5/10/2010 12:19:11 AM

Tombo H <tombo.hayworth@gmail.com> wrote in message <b2bbce34-7df3-4c80-ae09-3e549283274a@j35g2000yqm.googlegroups.com>...
> On May 9, 6:30 pm, "Sami Oueslati" <Samy...@yahoo.fr> wrote:
> How I put the values obtained in a matrix that has the size (nb of
> regions in x direction X nb of regions in y direction)??
> ----------------------------------------------------------------------
> I don't understand the question.  Can you supply an example?
> 
> Do you mean
> centralValues(tileY, tileX) = ImageGris(x,y);
> 
> ??????
---------------------------------------------------------------------------
here's an image that explains more than thousand words :) http://drop.io/mqlwmho#
0
Reply Sami 5/10/2010 12:57:03 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <9bc3b7c2-a68c-484f-ab7b-1e96a5df7897@b18g2000yqb.googlegroups.com>...
> Sami Oueslati:
> I'm not sure exactly what you're after.....I guess I don't quite
> understand the grammar.
-----------------------------------------------------------------------------------------------------
Hi ImageAnalyst,
Here's an image that explains what I want to do ---> http://drop.io/mqlwmho#
0
Reply Sami 5/10/2010 8:32:24 PM

On May 10, 4:32=A0pm, "Sami Oueslati" <Samy...@yahoo.fr> wrote:
> Hi ImageAnalyst,
> Here's an image that explains what I want to do --->http://drop.io/mqlwmh=
o#
-----------------------------------------------------------------------
It looks like each tile is replaced by the value of the center (kind
of a strange thing to want to do), but not exactly because there are
still some non-uniform gray levels around the border - but maybe
that's just because you mocked it up in Photoshop or something.

So just do something like this

outputImage(tileTopRow:tileBottomRow, tileLeftCol:tileRightCol) =3D
inputImage(tileCenterRow, tileCenterCol);


0
Reply ImageAnalyst 5/10/2010 10:19:06 PM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <26535f93-cbe2-4774-a129-cc08bb1d849b@r11g2000yqa.googlegroups.com>...
> On May 10, 4:32 pm, "Sami Oueslati" <Samy...@yahoo.fr> wrote:

> It looks like each tile is replaced by the value of the center (kind
> of a strange thing to want to do), but not exactly because there are
> still some non-uniform gray levels around the border - but maybe
> that's just because you mocked it up in Photoshop or something.
> 
> So just do something like this
> 
> outputImage(tileTopRow:tileBottomRow, tileLeftCol:tileRightCol) =
> inputImage(tileCenterRow, tileCenterCol);
_________________________________________________________________________
Thanks ImageAnalyst, I got it...please now, how to transform the tiles in uniform squares? as here http://drop.io/mqlwmho#
0
Reply Samiov 5/12/2010 12:02:05 AM

On May 11, 8:02=A0pm, "Samiov " <Samy...@yahoo.fr> wrote:
> ImageAnalyst <imageanal...@mailinator.com> wrote in message <26535f93-cbe=
2-4774-a129-cc08bb1d8...@r11g2000yqa.googlegroups.com>...
> > On May 10, 4:32=A0pm, "Sami Oueslati" <Samy...@yahoo.fr> wrote:
> > It looks like each tile is replaced by the value of the center (kind
> > of a strange thing to want to do), but not exactly because there are
> > still some non-uniform gray levels around the border - but maybe
> > that's just because you mocked it up in Photoshop or something.
>
> > So just do something like this
>
> > outputImage(tileTopRow:tileBottomRow, tileLeftCol:tileRightCol) =3D
> > inputImage(tileCenterRow, tileCenterCol);
>
> _________________________________________________________________________
> Thanks ImageAnalyst, I got it...please now, how to transform the tiles in=
 uniform squares? as herehttp://drop.io/mqlwmho#

---------------------------------------------------------------------------=
-------
Just do something like this:
outputImage(tileTopRow:tileBottomRow, tileLeftCol:tileRightCol) =3D
inputImage(tileCenterRow, tileCenterCol);

I believe I've given you code somewhere above on how to scan your
image.  Just add this part in.  I can't spend the time to write the
whole complete app for you.  Why do you want to make that output image
anyway?  What good is it?
0
Reply ImageAnalyst 5/12/2010 2:27:12 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <a96f4b4b-5742-4b75-a860-8d59cbf8a9f9@t17g2000yqg.googlegroups.com>...
> On May 11, 8:02 pm, "Samiov " <Samy...@yahoo.fr> wrote:
> > ImageAnalyst <imageanal...@mailinator.com> wrote in message <26535f93-cbe2-4774-a129-cc08bb1d8...@r11g2000yqa.googlegroups.com>...
> ----------------------------------------------------------------------------------
> Just do something like this:
> outputImage(tileTopRow:tileBottomRow, tileLeftCol:tileRightCol) =
> inputImage(tileCenterRow, tileCenterCol);
> 
> I believe I've given you code somewhere above on how to scan your
> image.  Just add this part in.  I can't spend the time to write the
> whole complete app for you.  Why do you want to make that output image
> anyway?  What good is it?
---------------------------------------------------------------------------------------

Hi, I've done what you said..You thought that I was asking the same question but I've asked you something else...Now that I have the tiles coloured with one graylevel, I want to transform the tiles (they have different rectangular form) in tiles that have a uniform square form (as a checker board)

I've modified the image "explication" that I've added previously, maybe you thought It was the same image.
--> http://drop.io/mqlwmho#

I'm doing this because as you see, the original image is a woven fabric and I want to identify when the vertical yarn passes above and below the horizontal yarn --> I've constructed the grid to localize the intersections between yarns, and identifying the colour of the center of each tile, I conclude if the yarn passes above or below --> to finally have a simplified image (as a checker board) composed of white (vertical yarn above) and black (vertical yarn below) tiles.
0
Reply Samiov 5/12/2010 3:42:04 AM

Hi ImageAnalyst,
Here's the code, I've added what you said at the end of it, but what are the right indexes that I must choose to have my finalImage with tiles that have square's form and not rectangle's form as in my grayImage ???
Thanks, hope you'll be patient with me..
-----------------------------------------------------------------------------------------------
finalImage = grayImage;

LigneH = [1 LigneH lign];
LigneV = [1 LigneV col];
lastTileX = length(LigneH);
lastTileY = length(LigneV);

counter = 0;
for tileX = 1 : lastTileX-1
    column1 = LigneH(tileX)
    column2 = LigneH(tileX+1)
    if column1 > col || column2 > col
        % Skip bad ones.
        continue;
    end
    for tileY = 1 : lastTileY-1
        row1 = LigneV(tileY)
        row2 = LigneV(tileY+1)
        if row1 > lign || row2 > lign
            % Skip bad ones.
            continue;
        end
        subImage = grayImage(row1:row2, column1:column2);
        counter = counter + 1
        xc = int32((column1 + column2)/2);
        yc = int32((row1 + row2)/2);
        pixelValue = grayImage(xc,yc);
        finalImage (row1:row2, column1:column2) = pixelValue; 
    end
end
0
Reply Samiov 5/13/2010 1:33:04 AM

ImageAnalyst <imageanalyst@mailinator.com> 
------------------------------------------------------------------------------------
> I believe I've given you code somewhere above on how to scan your
> image.  Just add this part in.  I can't spend the time to write the
> whole complete app for you.  Why do you want to make that output image
> anyway?  What good is it?
------------------------------------------------------------------------------------
Hi ImageAnalyst,
Sorry I must insist, cause I worked on it and nothing...please review this...

        xc = int32((column1 + column2)/2);
        yc = int32((row1 + row2)/2);
        finalImage (row1:row2, column1:column2) = grayImage(xc,yc)

Ok so my finalImage has a number of rectangular tiles (5x8) where each tile is coloured by the graylevel of the center of the correspondent tile of the original grayImage...that's done, ok...but now the tiles haven't the same size..I want to convert them to tiles that has a regular square size (we can say 100x100 each tile)...Pleaseeeeeee how to do it????!!!!!!!!!!!!
0
Reply Samiov 5/13/2010 9:32:04 PM

But your image is not such that they should be all the same size
squares so why do you want to do this?

In any event, one way is to just average together the widths and
heights of all the tiles and center the new tile sizes on each (old)
tile centroid.  Of course some tile edges will no longer align with
your fabric weave.


0
Reply ImageAnalyst 5/14/2010 12:20:52 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <d597391b-e906-427e-ad68-8d593882ed79@l28g2000yqd.googlegroups.com>...
> But your image is not such that they should be all the same size
> squares so why do you want to do this?
> 
> In any event, one way is to just average together the widths and
> heights of all the tiles and center the new tile sizes on each (old)
> tile centroid.  Of course some tile edges will no longer align with
> your fabric weave.
___________________________________________________________________________
I must do that cause in theory it's how we represent a fabric weave and it's the final result that I must reach.. the tiles must have a regular square's form so I thought that going all over the image with rectangular painted (gray level of centers) tiles, I can construct an image that respects more the theory and has a regular tile's form (100x100)
0
Reply Samiov 5/14/2010 12:40:06 AM

On May 13, 8:40=A0pm, "Samiov " <Samy...@yahoo.fr> wrote:
> I must do that cause in theory it's how we represent a fabric weave and i=
t's the final result that I must reach.. the tiles must have a regular squa=
re's form so I thought that going all over the image with rectangular paint=
ed (gray level of centers) tiles, I can construct an image that respects mo=
re the theory and has a regular tile's form (100x100)
---------------------------------------------------------------------------=
------
And what if you have a satin weave or basketweave?  They're not
square.
0
Reply ImageAnalyst 5/14/2010 12:43:34 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <5506725e-63b5-4bfd-86cd-b60333b079b9@k29g2000yqh.googlegroups.com>...
> On May 13, 8:40 pm, "Samiov " <Samy...@yahoo.fr> wrote:
> > I must do that cause in theory it's how we represent a fabric weave and it's the final result that I must reach.. the tiles must have a regular square's form so I thought that going all over the image with rectangular painted (gray level of centers) tiles, I can construct an image that respects more the theory and has a regular tile's form (100x100)
> ---------------------------------------------------------------------------------
> And what if you have a satin weave or basketweave?  They're not
> square.
------------------------------------------------------------------------------------------------------
It's always the same..even if the yarns are thinner or more thick, the fabric is always represented in this way (plain, satin, twill,...) cause here, we are interested sin the intersections between yarns...This will help us on reproduce it...the thickness will be taken in consideration after...
0
Reply Samiov 5/14/2010 12:55:21 AM

Good morning ImageAnalyst,
Hope you understood what I said.. At the end, the image must look like a checker board..if the square's tile is white, then it means that the vertical yarn is in high position and if it's black it's in low position. Hope there's a method to detect the colour of each tile (that now each one has a unique gray colour) and to put it in a new image composed of the same number of tiles but these tiles have a uniform size (100 x 100 for example).
It will be great if we reach this step and finally finish the work.
0
Reply Samiov 5/14/2010 7:36:08 AM

"Samiov " <Samyw69@yahoo.fr> wrote in message <hsiuh8$oml$1@fred.mathworks.com>...
> Good morning ImageAnalyst,
> Hope you understood what I said.. At the end, the image must look like a checker board..if the square's tile is white, then it means that the vertical yarn is in high position and if it's black it's in low position. Hope there's a method to detect the colour of each tile (that now each one has a unique gray colour) and to put it in a new image composed of the same number of tiles but these tiles have a uniform size (100 x 100 for example).
> It will be great if we reach this step and finally finish the work.
__________________________________________________________________________
To avoid confusions due to my bad english, Here's what I want to do:
http://drop.io/mqlwmho#
I've tried all day to solve it but I can't
please it's urgent for me
0
Reply Samiov 5/15/2010 12:14:07 AM

Please ImageAnalyst...I must reach this point before wednesday and I depend on you
http://drop.io/mqlwmho#
0
Reply Samiov 5/15/2010 10:06:05 PM

Please, tell me at least the steps that I must take... 
0
Reply Samiov 5/16/2010 2:34:04 PM

Hi again ImageAnalyst, please tell me if there's anything you can do?? cause I'm really lost..I must have a solution for tomorrow and I have no one to help me on this..
0
Reply Samiov 5/18/2010 9:57:03 AM

On May 18, 5:57=A0am, "Samiov " <Samy...@yahoo.fr> wrote:
> Hi again ImageAnalyst, please tell me if there's anything you can do?? ca=
use I'm really lost..I must have a solution for tomorrow and I have no one =
to help me on this..

-----------------------------------------------------------------
Why don't you just post all your code, starting from imread(), in one
place. such as http://drop.io.  I'm pretty busy today so I may not be
able to offer any more hints.  Why is it due tomorrow?  Is it a
student project, or your client is coming in for a site visit?
0
Reply ImageAnalyst 5/18/2010 10:18:22 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <25fc9fa1-b6ed-4d0d-bd11-b067a27bfde2@q13g2000vbm.googlegroups.com>...
> On May 18, 5:57 am, "Samiov " <Samy...@yahoo.fr> wrote:
> > Hi again ImageAnalyst, please tell me if there's anything you can do?? cause I'm really lost..I must have a solution for tomorrow and I have no one to help me on this..
> 
> -----------------------------------------------------------------
> Why don't you just post all your code, starting from imread(), in one
> place. such as http://drop.io.  I'm pretty busy today so I may not be
> able to offer any more hints.  Why is it due tomorrow?  Is it a
> student project, or your client is coming in for a site visit?
____________________________________________________________________
Thanks yes it's for a student project...Here's the code with the original image and an explanation of what I want to do.. http://drop.io/mqlwmho#
thanks again!!!
0
Reply Samiov 5/18/2010 11:00:22 AM

 ____________________________________________________________________
> Thanks yes it's for a student project...Here's the code with the original image and an explanation of what I want to do.. http://drop.io/mqlwmho#
> thanks again!!!
0
Reply Samiov 5/19/2010 1:15:23 AM

"Samiov " <Samyw69@yahoo.fr> wrote in message <hsve3b$7mr$1@fred.mathworks.com>...
>  ____________________________________________________________________
> > Thanks yes it's for a student project...Here's the code with the original image and an explanation of what I want to do.. http://drop.io/mqlwmho#
> > thanks again!!!
0
Reply Samiov 5/19/2010 2:28:04 AM

yes it's for a student project...Here's the code with the original image and an explanation of what I want to do.. http://drop.io/mqlwmho#
thanks again!!!
0
Reply Samiov 5/19/2010 4:34:20 PM

Samiov wrote:
> yes it's for a student project...Here's the code with the original image 
> and an explanation of what I want to do.. http://drop.io/mqlwmho#

There are some images there, and there is code there, but there does not 
appear to be an explanation of what you are trying to do. Your image 
with the arrows is not clear, and it is not clear why you map the 
opening at the bottom left to a completely empty square in the 
right-hand image.
0
Reply Walter 5/19/2010 4:43:49 PM

58 Replies
341 Views

(page loaded in 0.516 seconds)


Reply: