Credible fruit traceability method and device based on fruit texture atlas and blockchain
Abstract
The present invention discloses a credible fruit traceability method and device based on fruit texture atlas and blockchain. According to the present invention, images of fruit pedicel part and fruit navel part of a single fruit are obtained, and the images are grayed and normalized to be converted into rectangular images; features are extracted from the rectangular images, respectively, and are encoded to obtain a fruit pedicle feature code table and a fruit navel feature code table; the two feature code tables are subjected to a merging operation to obtain a combined bidirectional feature code table, thus forming a unique fruit texture atlas. By processing the fruit texture atlas, the fruit texture atlas information and related information are stored on the blockchain. The user uses the same algorithm to obtain a fruit texture atlas of a fruit to be inspected through a smart terminal, the fruit texture atlas is processed and then is compared with the information on the blockchain for verification, so as to achieve the purpose of credible traceability. The present invention realizes the uniqueness and convenience of fruit identification, solves the problem of information tampering by evidence storage on the blockchain, and achieves the purpose of credible traceability.
Claims
exact text as granted — not AI-modifiedWhat is claimed is:
1. A computer-implemented encoding method of fruit texture atlas information, the computer-implemented encoding method comprising:
obtaining an image of fruit pedicel part and an image of fruit navel part, of a fruit to be encoded;
graying the image of fruit pedicel part and the image of fruit navel part, respectively, and normalizing the images to transform the images into a rectangular image of fruit pedicel part and a rectangular image of fruit navel part;
extracting features from the rectangular image of fruit pedicel part and the rectangular image of fruit navel part, respectively, encoding the features to obtain a fruit pedicel feature code table and a fruit navel feature code table; and
performing a merging operation on the fruit pedicel feature code table and the fruit navel feature code table to obtain a combined bidirectional feature code table, thereby forming a fruit texture atlas that uniquely identifies the fruit.
2. The computer-implemented encoding method according to claim 1 , wherein normalizing the images to transform the images into a rectangular image of fruit pedicel part and a rectangular image of fruit navel part comprises:
positioning outer edges of the fruit pedicel part and of a core of the fruit navel part according to a difference between gray levels of the fruit pedicel part and of an external skin in the image of fruit pedicel part and according to a difference between gray levels of the fruit navel part and of the external skin in the image of fruit navel part, and extracting center positions of the fruit pedicel part and the fruit navel part;
drawing two concentric circles by taking the extracted center positions of the fruit pedicel part and the fruit navel part as centers of circles and taking predetermined distances R 1 and R 2 from centers to edges of the fruit pedicel part and of the fruit navel part as radiuses of circles, and extracting a circular ring between the two concentric circles as an area to be processed; and
normalizing the area to be processed by:
I ( x ( r ,θ), y ( r ,θ))→ I ( r ,θ),
wherein,
{
x
(
r
,
θ
)
=
(
1
-
r
)
x
i
(
θ
)
+
rx
0
(
θ
)
y
(
r
,
θ
)
=
(
1
-
r
)
y
i
(
θ
)
+
ry
0
(
θ
)
,
wherein, I (x,y) represents an image of the circular ring; (r,θ) represents normalized polar coordinates, r∈[0,1], θ∈[0°,360°]; when r=0, it indicates that I (x(r,θ,y(r,θ)) is a pixel point at an inner edge of the image of the circular ring; when r=1, it indicates that I (x(r,θ,y(r,θ)) is a pixel point at an outer edge of the image of the circular ring; (r, θ) of each point (x i , y i ) in the area to be processed is determined by considering a relationship of the each point with a center point (x 0 , y 0 ), and the image of the circular ring is transformed into a rectangular image I(r,θ) by taking r and θ as rectangular coordinates.
3. The computer-implemented encoding method according to claim 2 , further comprising performing a histogram equalization to the transformed rectangular image of fruit pedicel part and the transformed rectangular image of fruit navel part, respectively, to enhance the rectangular images, thereby obtaining a clearer texture;
wherein performing a histogram equalization is expressed as:
S
(
r
k
)
=
T
(
r
k
)
=
1
N
∑
i
=
0
k
N
(
r
k
)
,
wherein N is a total number of pixels of the rectangular image to be enhanced, N(r k ) is the number of pixels with a gray level of r k , k is a gray level number, T(r k ) is a transfer function for the gray level of r k , and S(r k ) is a transformed gray level.
4. The computer-implemented encoding method according to claim 1 , wherein extracting features from the rectangular image of fruit pedicel part and the rectangular image of fruit navel part respectively and encoding the features to obtain a fruit pedicel feature code table and a fruit navel feature code table comprises:
extracting an average energy value u and a variance o of each channel by using Haar wavelet transform and performing a K-means clustering to obtain an image of the circular ring of a small sample set;
extracting texture information of the image of the circular ring by using two-dimensional Gabor filtering to obtain a corresponding texture feature parameter; wherein an expression of the two-dimensional Gabor filtering is:
G
(
x
,
y
)
=
exp
(
-
x
1
2
+
y
1
2
2
σ
2
)
exp
(
i
2
π
x
1
λ
)
,
wherein x 1 =x cos θ+y sin θ, y 1 =−x sin θ+y cos θ, λ is a wavelength specified in pixels, and θ represents a direction;
C3, after obtaining the texture feature parameter, determining a positivity or a negativity of a real part and an imaginary part of a coefficient of the texture feature parameter to perform quantitative encoding, comprising:
h
Re
=
{
1
Re
{
ifft
(
G
(
f
)
·
fft
(
I
(
r
)
)
)
}
≥
0
0
Re
{
ifft
(
G
(
f
)
·
fft
(
I
(
t
)
)
}
}
<
0
(
r
=
1
,
2
,
3
,
…
,
N
)
,
h
Im
=
{
1
Re
{
ifft
(
G
(
f
)
·
fft
(
I
(
r
)
)
)
}
≥
0
0
Re
{
ifft
(
G
(
f
)
·
fft
(
I
(
t
)
)
)
}
<
0
(
r
=
1
,
2
,
3
,
…
,
N
)
,
wherein h Re and h Im represent the real part and the imaginary part of the texture feature parameter obtained through filtering, respectively; fft represents a Fourier transform; and ifft represents a Fourier inversion.
5. The computer-implemented encoding method according to claim 1 , wherein performing a merging operation on the fruit pedicel feature code table and the fruit navel feature code table to obtain a combined bidirectional feature code table comprises:
T=T A ∪T B ={X (i,j) |X (i,j) ∈T A or X (i,j) ∈T B },
wherein T represents the combined bidirectional feature code table, T A and T B represent the fruit pedicel feature code table and the fruit navel feature code table, respectively, and X (i, j) is a value corresponding to row i and column j in the bidirectional feature code table.
6. An identification method based on fruit texture atlas, comprising:
obtaining a fruit texture atlas of a reference fruit by the computer-implemented encoding method according to claim 1 ;
performing an image feature encoding to a fruit to be identified to obtain a feature code table, and matching the obtained feature code table with a feature code table of the fruit texture atlas of the reference fruit so as to identify feature information of the fruit texture atlas.
7. The identification method according to claim 6 , wherein performing the image feature encoding comprises:
performing the matching by using a classifier based on Hamming distance (HD), which is calculated by a formula of:
HD
=
1
N
∑
j
=
1
N
P
j
(
XOR
)
Q
j
,
wherein N is a bit number of texture feature code, XOR represents an exclusive-OR operation, and P j and Q j represent a j th bit of texture feature codes P and Q, respectively;
if a determined HD is greater than a predetermined first threshold value, it's judged that the fruit to be identified is different from the reference fruit; if the determined HD is less than the predetermined first threshold value, it's judged that the fruit to be identified is the same fruit with the reference fruit.
8. The identification method according to claim 7 , wherein performing the image feature encoding comprises:
identifying the feature information of the fruit texture atlas according to the combined bidirectional feature code table, firstly;
if it is judged that the fruit to be identified is the same fruit with the reference fruit, the identification is ended; otherwise, if a difference between the determined HD and the predetermined first threshold value is less than a predetermined difference value, the feature information is further identified according to the fruit pedicle feature code table and the fruit naval feature code table extracted from the bidirectional feature code table, respectively; and
if one of the determined HDs obtained according to the fruit pedicle feature code table and the fruit naval feature code table is less than the predetermined first threshold value, it is only necessary to determine the other one of the determined HDs being less than a predetermined second threshold value to judge that the fruit to be identified is the same fruit with the reference fruit, and the identification is ended.Cited by (0)
No later patents cite this yet.
References (0)
No backward citations on record.