[ITK] [ITK-users] Offset directions
med aweng
medswengineer at gmail.com
Tue Jul 22 08:05:30 EDT 2014
>
> Thanks a lot Marco for your thorough explanation. I know how the degrees
> will look like, but, the main issue was for instance why 45 degrees' offset
> is {1,-1}, and likewise for the other degrees. Is that just a convention?
> Or, there is a way to find that 45 degrees is {1,-1}?
>
> Thanks.
>
>
> On Tue, Jul 22, 2014 at 12:52 PM, Marco Ulgelmo <marco.ulge at gmail.com>
> wrote:
>
>> Let's make an example, let's suppose that you have a 4x4 matrix defined
>> this way:
>>
>> A = [0, 1, 0, 2
>> 0, 2 , 1, 1
>> 3, 1, 0, 0
>> 0, 0, 2, 3]
>>
>> with distance 1 and direction = 45 degrees
>>
>> The GLCM associated to A will be a 4x4 matrix because values in A are
>> from 0 to 3. If A had values ranging from 0 to 7 than the GLCM would have
>> been 8x8. GLCM by definition tells you the grey level occurrences.
>>
>> Now our goal is to understand how we should populate the GLCM matrix.
>> Let's start from GLCM[0][0]. Since as i said before the GLCM tells you the
>> occurrences in gray level, GLCM[0][0] will be the number of occurrences of
>> (0, 0) according to 45 degrees.
>> So you take each pixel in the A matrix which is 0 and count the pairs for
>> each 0 which has a 0 with distance 1 in its 45 degree diagonal. In A we can
>> easily observe the only A[3][1] satisfies this property, in fact we take
>> take pixel, we notice that the pixel according to 45 degree direction will
>> be 0 so we found a pair (0,0) with the required direction.
>>
>> Since there is only 1 occurrence of (0, 0) with direction= 45 degrees,
>> GLCM[0][0] will be 1 (infact 1 is the number of occurrences).
>>
>> In the same way, GLCM[1][0] will look for all the occurrences of pair
>> (1,0) with direction 45 degrees and we can observe that there are no
>> occurrences in A so GLCM[1][0] = 0.
>>
>> GLCM[2][0] = 2 (A[1][1] and A[3][2] satify the direction) and so on.
>>
>> I suggest you taking a look at this example:
>> http://www.itk.org/Wiki/ITK/Examples/Statistics/TextureFeatures
>>
>> Beside what this code does (which is not what you are looking for maybe),
>> you can see that it's enough changin the line
>>
>> glcmGenerator->SetOffset(offset);
>>
>>
>> with the offset you want.
>>
>>
>> If you need to compute GLCM for different directions (obtaining a single
>> GLCM as result), you first compute GLCM for each direction and then compute
>> finalGLCM as a mean of the others GLCM
>>
>> Regards,
>>
>> Marco
>>
>>
>> 2014-07-22 12:13 GMT+02:00 med aweng <medswengineer at gmail.com>:
>>
>> Dear Marco,
>>>
>>> Thanks a lot for your reply and very helpful answer. For instance, when
>>> we say that {1,-1} is 45 degrees. How can this be understood geometrically?
>>> In other words, say that I have an image represented as a set of pixels
>>> (squares). How can I derive that {1,-1} for instance mean 45 degrees, and
>>> likewise for the other degrees?
>>>
>>> Thanks.
>>>
>>>
>>> On Tue, Jul 22, 2014 at 10:39 AM, Marco Ulge <marco.ulge at gmail.com>
>>> wrote:
>>>
>>>> Offsets are defined in ITK wether you are using them for GLCM or
>>>> Neighborhood
>>>> Iterators for example. I believe you can find a complete list off
>>>> offset in
>>>> the Software Guide in the Neighborhood Iterator section (chapter 11).
>>>>
>>>> Anyway here's the list of offsets (with distance = 1):
>>>>
>>>> 0 degree : {1,0}
>>>> 45 degree: {1, -1}
>>>> 90 degree: {0,-1}
>>>> 135 degree: {-1,-1}
>>>> 180 degree: {-1,0}
>>>> 225 degree: {-1,1}
>>>> 270 degree: {0,1}
>>>> 315 degree: {1,1}
>>>>
>>>> Please notice that there is no offset for 35 degrees, that just doesn't
>>>> make
>>>> sense
>>>>
>>>> Marco
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://itk-users.7.n7.nabble.com/ITK-users-Offset-directions-tp34274p34277.html
>>>> Sent from the ITK - Users mailing list archive at Nabble.com.
>>>> _____________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Kitware offers ITK Training Courses, for more information visit:
>>>> http://www.kitware.com/products/protraining.php
>>>>
>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://public.kitware.com/mailman/listinfo/insight-users
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140722/e937f9e5/attachment-0002.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
More information about the Community
mailing list