Borrar filtros
Borrar filtros

Confusion in the tamura texture directionality code

5 visualizaciones (últimos 30 días)
Donghui  Sun
Donghui Sun el 23 de Sept. de 2013
Editada: Azim MAAE el 28 de Mzo. de 2017
I have some codes to calculate tamura texture directionality. The code likes that:
% code
function [ Fdir ] = tamura_dir( Im )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
% Get the gradient,imclude the magnitude and direction.
[gx, gy] = gradient(Im);
[theta,rho] = cart2pol(gx,gy);
% Calculate the histgram.
nbins = 125;
rho(rho<.15.*max(rho(:))) = 0;
t0 = theta;
t0(abs(rho)<1e-4) = 0;
rho = rho(:)';
t0 = t0(:)';
Hd = hist(t0, nbins);
% Measure the sharpness of peaks.
(1) nrm = hist(rho(:).^2+t0(:).^2, nbins); ??
(2) fmx = find(Hd==max(Hd));
(3) ff = 1:length(Hd);
(4) ff2 = (ff - fmx).^2;
(5) Fdir = sum(Hd.*ff2)./sum(nrm); ??
(6) Fdir = abs(log(Fdir+eps)); ??
end
The code has three steps;The first two steps are used to computed the gradient and the the histogram of the direction of the gradient. And they are not hard to understand. But I have some confusion in the third step. I write two ?? on the behind of that three sentences.
On the basis of the definition of the tamura texture directionality. The third step should be measuring the sharpness of the histogram that have been obtained on the second step. But the code in the third step are different with the definition .
I don not know what the nrm means and why calculate the histogram of nrm. Any suggestion?
  1 comentario
Azim MAAE
Azim MAAE el 28 de Mzo. de 2017
Editada: Azim MAAE el 28 de Mzo. de 2017
This is a very old question, but since it had 30 view during the last month, I am going to give it a try.
This is a non-working code, however, it is a good starting point.
  • The following line is wrong since ff and fmx are of different sizes:
ff2 = (ff - fmx).^2;
  • To understand the idea, see the formula in the original paper .
  • nrm is the normalization factor. ( r in Tamura's formula)
  • And finally, yes! The code in the 3rd step (in my opinion) didn't implemented the actual Tamura's idea. The sharpness (or peaks) of the histogram should be considered as local maximums; a vector of weights ( ff2 ) should be constructed for the range of each peak (and not for the entire domain!!!). This vector gives a parabola of weights and this is the key part. See below:
vector of weights ( ff2)
Suppose the interval for a peak is v = {1,2,3,4}. The weight vector corresponding to v if hist(2) is a peak will be ff2 = {(2-1)^2, (2-2)^2, (2-3)^2, (2-4)^2 }.
More:
  1. Another Matlab implementation of Tamura parameters .
  2. A good reading about this: CBIR

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by