2012-04-01 11 views
5

मैं सीमा के फूरियर डिस्क्रिप्टर प्राप्त करने के लिए गोंज़ालेज़ frdescp फ़ंक्शन का उपयोग कर रहा हूं। मैं इस कोड का उपयोग करता हूं, और मुझे संख्याओं के दो अलग-अलग सेट मिलते हैं जो दो समान लेकिन स्केल आकारों में भिन्न होते हैं।मैटलैब चौकोर वर्णनकर्ता क्या गलत है?

तो क्या गलत है?

im = imread('c:\classes\a1.png'); 
im = im2bw(im); 
b = bwboundaries(im); 
f = frdescp(b{1}); // fourier descriptors for the boundary of the first object (my pic only contains one object anyway) 
// Normalization 
f = f(2:20); // getting the first 20 & deleting the dc component 
f = abs(f) ; 
f = f/f(1); 

मुझे समान के लिए अलग-अलग वर्णनकर्ता क्यों मिलते हैं - लेकिन स्केल में दो अलग-अलग सर्कल?

+0

आप कहाँ से frdescp प्राप्त किया? यह समस्या का स्रोत हो सकता है – Rasman

+0

मुझे इसे MATLAB पुस्तक का उपयोग करके गोंज़ालेज की डिजिटल छवि प्रसंस्करण से मिला, वास्तव में मुझे लगता है कि bwboundaries समस्या है! –

+0

मैंने संपादित किया [मेरा पिछला उत्तर] (http://stackoverflow.com/a/23741097/738017), मुझे आशा है कि यह आपके और अन्य उपयोगकर्ताओं के लिए उपयोगी हो सकता है। –

उत्तर

6

समस्या यह है कि frdescp कोड (मैंने this code का उपयोग किया था, जो आपके द्वारा संदर्भित जैसा ही होना चाहिए) फूरियर डिस्क्रिप्टर को केन्द्रित करने के लिए भी लिखा गया है।

यदि आप सही तरीके से अपने आकार का वर्णन करना चाहते हैं, तो डीसी घटक का प्रतिनिधित्व करने वाले व्यक्ति के संबंध में सममित होने वाले कुछ वर्णनकर्ताओं को समझना अनिवार्य है।

निम्न छवि अवधारणा को संक्षेप में:

Cut-off of less significant descriptors

आपकी समस्या (और आपके जैसे अन्य) हल करने के लिए, मैं निम्नलिखित दो कार्यों लिखा है:

function descriptors = fourierdescriptor(boundary) 
    %I assume that the boundary is a N x 2 matrix 
    %Also, N must be an even number 

    np = size(boundary, 1); 

    s = boundary(:, 1) + i*boundary(:, 2); 

    descriptors = fft(s); 

    descriptors = [descriptors((1+(np/2)):end); descriptors(1:np/2)]; 
end 

function significativedescriptors = getsignificativedescriptors(alldescriptors, num) 
    %num is the number of significative descriptors (in your example, is was 20) 
    %In the following, I assume that num and size(alldescriptors,1) are even numbers 

    dim = size(alldescriptors, 1); 

    if num >= dim 
     significativedescriptors = alldescriptors; 
    else 
     a = (dim/2 - num/2) + 1; 
     b = dim/2 + num/2; 

     significativedescriptors = alldescriptors(a : b); 
    end 
end 

पता है, तुम उपर्युक्त कार्यों का उपयोग निम्नानुसार कर सकते हैं:

im = imread('test.jpg'); 
im = im2bw(im); 
b = bwboundaries(im); 
b = b{1}; 

%force the number of boundary points to be even 
if mod(size(b,1), 2) ~= 0 
    b = [b; b(end, :)]; 
end 

%define the number of significative descriptors I want to extract (it must be even) 
numdescr = 20; 

%Now, you can extract all fourier descriptors... 
f = fourierdescriptor(b); 
%...and get only the most significative: 
f_sign = getsignificativedescriptors(f, numdescr); 
2

मैं बस तुम्हारे साथ एक ही समस्या से गुजर गया।

इस link के अनुसार, यदि आप स्केलिंग के लिए आविष्कार चाहते हैं, तो तुलना अनुपात की तरह बनाएं, उदाहरण के लिए डीसी-गुणांक द्वारा प्रत्येक फूरियर गुणांक को विभाजित करके। एफ * 1 = एफ 1/एफ [0], एफ * [2]/एफ [0], और इसी तरह। इस प्रकार, आपको डीसी-गुणांक का उपयोग करने की आवश्यकता है जहां आपके कोड में एफ (1) आपके चरण "एफ = एफ (2:20) के बाद वास्तविक डीसी-गुणांक नहीं है;% पहले 20 & डीसी घटक को हटा रहा है" । मुझे लगता है कि डीसी-गुणांक के मूल्य को पहले रखकर समस्या हल की जा सकती है, समायोजित किए जाने के बाद कोड निम्नानुसार होना चाहिए:

% Normalization 
DC = f(1); 
f = f(2:20); % getting the first 20 & deleting the dc component 
f = abs(f) ; % use magnitudes to be invariant to translation & rotation 
f = f/DC; % divide the Fourier coefficients by the DC-coefficient to be invariant to scale 
संबंधित मुद्दे