From: omo_ewa on 23 Nov 2009 13:53 Hello all, I am new to using matlab for any serious coding. However, I will like to be able to recognize specific colors (green, red, blue, black, etc.) in a scene of different color blocks of different colors. So, a sample will be to recognize a yellow-triangle block in a scene of yellow-triangular block, blue-square block, red-circular block. Thank you for your help! omo_ewa
From: jrenfree on 23 Nov 2009 14:27 On Nov 23, 10:53 am, omo_ewa <morenike.aj...(a)gmail.com> wrote: > Hello all, > > I am new to using matlab for any serious coding. However, I will like > to be able to recognize specific colors (green, red, blue, black, > etc.) in a scene of different color blocks of different colors. So, a > sample will be to recognize a yellow-triangle block in a scene of > yellow-triangular block, blue-square block, red-circular block. Thank > you for your help! > > omo_ewa Generally, colors are described by a combination of their RGB (red, green, and blue) values. These values range between 0 and 255. In Matlab, an image will typically be given by an MxNx3 matrix that gives the RGB values for each pixel of an image. You will need to determine the RGB ranges that coincide with the colors you want to detect and use some sort of thresholding in your image matrix to pick those colors out. There are other ways to do it, such as converting the image to HSV (hue, saturation, and value) values instead of RGB.
From: omo_ewa on 23 Nov 2009 14:41 On Nov 23, 2:27 pm, jrenfree <jrenf...(a)gmail.com> wrote: > On Nov 23, 10:53 am, omo_ewa <morenike.aj...(a)gmail.com> wrote: > > > Hello all, > > > I am new to using matlab for any serious coding. However, I will like > > to be able to recognize specific colors (green, red, blue, black, > > etc.) in a scene of differentcolorblocks of different colors. So, a > > sample will be to recognize a yellow-triangle block in a scene of > > yellow-triangular block, blue-square block, red-circular block. Thank > > you for your help! > > > omo_ewa > > Generally, colors are described by a combination of their RGB (red, > green, and blue) values. These values range between 0 and 255. In > Matlab, an image will typically be given by an MxNx3 matrix that gives > the RGB values for each pixel of an image. You will need to determine > the RGB ranges that coincide with the colors you want to detect and > use some sort of thresholding in your image matrix to pick those > colors out. > > There are other ways to do it, such as converting the image to HSV > (hue, saturation, and value) values instead of RGB. Hello jrenfree, Thank you for your help. It will be useful to me later on. But, do you have a sample that shows even how to start this. I know only so far how to read an image in to matlab. How do i code something that now checks for green in an image? What i am saying is that I don't know what to write. I have been checking online for a sample code i can work with, but i have not found any yet. I believe my problem is more basic. Thank you, omo_ewa
From: jrenfree on 23 Nov 2009 14:48 On Nov 23, 11:41 am, omo_ewa <morenike.aj...(a)gmail.com> wrote: > On Nov 23, 2:27 pm, jrenfree <jrenf...(a)gmail.com> wrote: > > > > > On Nov 23, 10:53 am, omo_ewa <morenike.aj...(a)gmail.com> wrote: > > > > Hello all, > > > > I am new to using matlab for any serious coding. However, I will like > > > to be able to recognize specific colors (green, red, blue, black, > > > etc.) in a scene of differentcolorblocks of different colors. So, a > > > sample will be to recognize a yellow-triangle block in a scene of > > > yellow-triangular block, blue-square block, red-circular block. Thank > > > you for your help! > > > > omo_ewa > > > Generally, colors are described by a combination of their RGB (red, > > green, and blue) values. These values range between 0 and 255. In > > Matlab, an image will typically be given by an MxNx3 matrix that gives > > the RGB values for each pixel of an image. You will need to determine > > the RGB ranges that coincide with the colors you want to detect and > > use some sort of thresholding in your image matrix to pick those > > colors out. > > > There are other ways to do it, such as converting the image to HSV > > (hue, saturation, and value) values instead of RGB. > > Hello jrenfree, > > Thank you for your help. It will be useful to me later on. But, do you > have a sample that shows even how to start this. I know only so far > how to read an image in to matlab. How do i code something that now > checks for green in an image? What i am saying is that I don't know > what to write. I have been checking online for a sample code i can > work with, but i have not found any yet. I believe my problem is more > basic. > > Thank you, > > omo_ewa Ok, so let's say you read in an image: A = imread('test.jpg'); The variable A should be some MxNx3 matrix. Now if we want to pick out all the green values from that matrix, we need to know the RGB values for green. Solid green would contain no red (R=0), full green (G=255), and no blue (B=0). We could pick those out by: idx = A(:,:,1) == 0 & A(:,:,2) == 255 & A(:,:,3) == 0; This is essentially saying to look for indices where the red color values equal 0, the green color values equal 255, and the blue color values equal 0. The result, idx, is a logical matrix that indexes into A to pick out only the pixels that are green.
From: omo_ewa on 23 Nov 2009 14:50 On Nov 23, 2:48 pm, jrenfree <jrenf...(a)gmail.com> wrote: > On Nov 23, 11:41 am, omo_ewa <morenike.aj...(a)gmail.com> wrote: > > > > > On Nov 23, 2:27 pm, jrenfree <jrenf...(a)gmail.com> wrote: > > > > On Nov 23, 10:53 am, omo_ewa <morenike.aj...(a)gmail.com> wrote: > > > > > Hello all, > > > > > I am new to using matlab for any serious coding. However, I will like > > > > to be able to recognize specific colors (green, red, blue, black, > > > > etc.) in a scene of differentcolorblocks of different colors. So, a > > > > sample will be to recognize a yellow-triangle block in a scene of > > > > yellow-triangular block, blue-square block, red-circular block. Thank > > > > you for your help! > > > > > omo_ewa > > > > Generally, colors are described by a combination of their RGB (red, > > > green, and blue) values. These values range between 0 and 255. In > > > Matlab, an image will typically be given by an MxNx3 matrix that gives > > > the RGB values for each pixel of an image. You will need to determine > > > the RGB ranges that coincide with the colors you want to detect and > > > use some sort of thresholding in your image matrix to pick those > > > colors out. > > > > There are other ways to do it, such as converting the image to HSV > > > (hue, saturation, and value) values instead of RGB. > > > Hello jrenfree, > > > Thank you for your help. It will be useful to me later on. But, do you > > have a sample that shows even how to start this. I know only so far > > how to read an image in to matlab. How do i code something that now > > checks for green in an image? What i am saying is that I don't know > > what to write. I have been checking online for a sample code i can > > work with, but i have not found any yet. I believe my problem is more > > basic. > > > Thank you, > > > omo_ewa > > Ok, so let's say you read in an image: > > A = imread('test.jpg'); > > The variable A should be some MxNx3 matrix. Now if we want to pick > out all the green values from that matrix, we need to know the RGB > values for green. Solid green would contain no red (R=0), full green > (G=255), and no blue (B=0). We could pick those out by: > > idx = A(:,:,1) == 0 & A(:,:,2) == 255 & A(:,:,3) == 0; > > This is essentially saying to look for indices where the red color > values equal 0, the green color values equal 255, and the blue color > values equal 0. The result, idx, is a logical matrix that indexes > into A to pick out only the pixels that are green. Thank you very much, I'll start from there. omo_ewa
|
Next
|
Last
Pages: 1 2 Prev: how can you restart CUMSUM Next: how can i compute probability map p-man |