An image credibility detection method, system, device and storage medium
By extracting and fusing visual features and metadata features of images, and combining them with a trained detection model, the problem of inaccurate image credibility assessment in existing technologies is solved, and a comprehensive and reliable assessment of image credibility is achieved.
Patent Information
- Application Number
- CN202510123818.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-26
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2045-01-26
AI Technical Summary
In existing technologies, image credibility assessment methods based solely on visual features or metadata are prone to misjudgment when faced with carefully tampered images, and cannot accurately assess image credibility when metadata is tampered with or missing.
By extracting visual features (color, texture, shape) from images and weighting them with metadata features, and then evaluating them using a trained credibility detection model, the accuracy and reliability of the evaluation are improved by combining visual content and generated background information.
It enables a comprehensive and reliable assessment of image credibility, effectively addresses complex scenarios, improves the accuracy and practicality of the assessment, and provides a reliable assessment method for fields that rely on image information.
Smart Images

Figure CN119600426B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image processing, in particular to an image credibility detection method, system, device and storage medium. BACKGROUND
[0002] In today's digital age, image information is growing explosively and is widely used in many fields such as news dissemination, social media, e-commerce, and judicial evidence. However, the development of digital image processing technology has also brought about a serious image credibility crisis. On the one hand, powerful image editing software such as Adobe Photoshop makes image forgery and tampering easy, from simple color adjustment to complex object addition or removal, all of which can be done without leaving obvious traces. On the other hand, the openness of the network makes the image source complex, and users have almost no effective means to judge the authenticity of the image when obtaining it.
[0003] Existing methods based only on visual features may misjudge carefully tampered images that look reasonable visually as credible. For example, some forged certificate images may not be able to find tampering traces through visual features alone, because the forger may keep the overall visual effect of the image consistent, but the present application can find abnormalities by combining metadata such as the original issuance time of the certificate with the shooting time in the image metadata. This single visual feature method lacks consideration of image sources and related background information, and is easily deceived by forgers.
[0004] Methods that rely only on metadata cannot accurately evaluate image credibility when metadata is tampered with or missing. Moreover, even if the metadata is normal, it is not possible to determine whether the image content has been tampered with based on metadata alone, and the visual feature analysis of the present application can make up for this deficiency. For example, if the metadata shows that the shooting device is normal, but the image content has obvious visual inconsistencies (such as the light and shadow effects of the object do not match the shooting device parameters), a method based only on metadata will not be able to identify this problem. SUMMARY
[0005] The main purpose of the present application is to provide an image credibility detection method, system, device and storage medium, which extracts visual features and metadata features of the target image, and performs weighted fusion, and then uses a trained credibility detection model for evaluation, aiming to improve the accuracy of image credibility evaluation, provide comprehensive evaluation means, and enhance the reliability and practicality of evaluation. This method can effectively deal with various complex scenarios and provide reliable evaluation means for various fields that rely on image information.
[0006] To achieve the above purpose, the embodiments of the present application provide the following technical solutions:
[0007] According to a first aspect of the embodiments of the present application, a method for detecting image credibility is provided, and the method comprises the following steps:
[0008] extracting visual features from a target image to be detected, wherein the visual features comprise color features, texture features and shape features;
[0009] weighting and fusing the visual features and metadata features to obtain a fused feature vector, wherein the metadata features represent image attribute information;
[0010] calling a credibility detection model to detect the credibility of the target image according to the fused feature vector.
[0011] Optionally, the visual features are extracted from the target image to be detected, and the extraction comprises the following steps:
[0012] converting the target image from an RGB color space to an HSV color space, and calculating a color histogram to generate color features;
[0013] converting the target image into a grayscale image, calculating a gray level co-occurrence matrix and extracting texture feature statistics to generate texture features;
[0014] performing edge detection and contour extraction on the target image to generate shape features.
[0015] Optionally, the color histogram is calculated to generate color features, and the calculation comprises the following steps:
[0016] determining the number and range of quantization intervals for each channel in the HSV color space;
[0017] initializing a vector with a length equal to the sum of the quantization interval numbers of all channels according to the quantization interval numbers of the channels;
[0018] starting from the first pixel of the target image, traversing each pixel in the target image row by row and column by column, and obtaining the H, S and V values of the pixel in the HSV space;
[0019] for the currently traversed pixel, calculating an index according to the H, S and V values in the HSV space and the quantization intervals, and updating the count at the corresponding position;
[0020] after traversing all the pixels, obtaining the color features representing the number of pixels in each quantization interval.
[0021] Optionally, the gray level co-occurrence matrix is calculated, and the texture feature statistics are extracted to generate texture features, and the calculation comprises the following steps:
[0022] initializing a gray level co-occurrence matrix according to a set gray level;
[0023] traversing each pixel in the target image row by row and column by column starting from a first pixel of the target image;
[0024] For each pixel, find a pixel pair corresponding to it according to a set distance and a set angle; obtain a gray level value of the pixel pair currently traversed, and add 1 to a value of a position in the gray level co-occurrence matrix;
[0025] After traversing all pixel pairs meeting the condition, the gray level co-occurrence matrix is constructed, and the gray level co-occurrence matrix represents a distribution of pixel pairs in different gray levels in the target image.
[0026] Calculate a texture feature statistic quantity by using the gray level co-occurrence matrix, arrange the texture feature statistic quantity in order, and generate a texture feature.
[0027] Optionally, the edge detection and contour extraction on the target image to generate a shape feature include:
[0028] Perform edge detection on the target image by using an edge detection algorithm to obtain an edge image;
[0029] Extract a contour from the edge image by using a contour extraction function; for each extracted contour, determine whether it is a closed contour;
[0030] Calculate a shape feature of each closed contour, and the shape feature includes an area of a region enclosed by the closed contour, a perimeter of the closed contour, a circularity, and an area of a minimum rectangle containing the closed contour.
[0031] Combine all the shape features into a vector as the shape feature.
[0032] Optionally, the calling of the credibility detection model to detect the credibility of the target image according to the fusion feature vector includes:
[0033] Input the fusion feature vector into the credibility detection model, and output a credibility score of the target image;
[0034] Determine whether the target image is credible according to a set threshold and the credibility score.
[0035] Optionally, the credibility detection model is trained according to the following steps:
[0036] Input a plurality of image samples with labeled credibility into a credibility detection model to be trained, and initialize model parameters;
[0037] The credibility detection model calculates a predicted credibility by forward propagation;
[0038] Calculate a loss function value according to the predicted credibility and the labeled credibility.
[0039] determining whether a condition for stopping the training is met according to the loss function value, and if the condition for stopping the training is not met, performing back propagation to calculate a gradient to update a model parameter;
[0040] if the condition for stopping the training is met, outputting the trained credibility detection model.
[0041] According to a second aspect of the embodiments of the present application, an image credibility detection system is provided, and the system comprises:
[0042] a feature extraction module configured to extract visual features from a target image to be detected, the visual features comprising color features, texture features and shape features;
[0043] a feature fusion module configured to perform weighted fusion of the visual features and metadata features to obtain a fusion feature vector, the metadata features representing image attribute information;
[0044] a credibility detection module configured to call a credibility detection model and detect credibility of the target image according to the fusion feature vector.
[0045] According to a third aspect of the embodiments of the present application, an electronic device is provided, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to implement the method of the first aspect.
[0046] According to a fourth aspect of the embodiments of the present application, a computer readable storage medium is provided, and the computer readable storage medium stores computer readable instructions executable by a processor to implement the method of the first aspect.
[0047] In summary, the embodiments of the present application provide an image credibility detection method, system, device and storage medium. The visual features of a target image to be detected are extracted, the visual features comprising color features, texture features and shape features. The visual features and metadata features are weighted and fused to obtain a fusion feature vector, the metadata features representing image attribute information. A credibility detection model is called, and credibility of the target image is detected according to the fusion feature vector. The visual features and metadata features of the target image are extracted and weighted and fused, and a trained credibility detection model is used for evaluation, aiming to improve the accuracy of image credibility evaluation, provide comprehensive evaluation means, and enhance the reliability and practicality of evaluation. This method can effectively deal with various complex scenarios and provide reliable evaluation means for various fields relying on image information. BRIEF DESCRIPTION OF DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings described below only show some of the embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from the structures shown in the drawings without creative labor.
[0049] The structures, proportions, sizes, etc. shown in the specification are only used to cooperate with the content disclosed in the specification, so that those skilled in the art can understand and read, and are not used to limit the conditions that can be implemented by the present application, so they do not have technical significance. Any modification of structure, change of proportion relationship or adjustment of size, which does not affect the effect and purpose that can be achieved by the present application, should still fall within the scope of the technical content disclosed by the present application.
[0050] Figure 1 A flowchart of an image credibility detection method provided by an embodiment of the present application is shown.
[0051] Figure 2 A system architecture diagram provided by an embodiment of the present application is shown.
[0052] Figure 3 A feature extraction flowchart provided by an embodiment of the present application is shown.
[0053] Figure 4 A model training diagram provided by an embodiment of the present application is shown.
[0054] Figure 5 A schematic diagram of an image credibility detection system provided by an embodiment of the present application is shown.
[0055] Figure 6 A structural diagram of an electronic device provided by an embodiment of the present application is shown.
[0056] Figure 7 A diagram of a computer readable storage medium provided by an embodiment of the present application is shown.
[0057] The implementation of the present application, functional features and advantages will be further described with reference to the drawings. DETAILED DESCRIPTION
[0058] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of the present application.
[0059] In addition, the technical solutions among various embodiments of the present application can be combined with each other, but it must be based on that a person skilled in the art can realize, when the combination of technical solutions appears contradictory or cannot be realized, it should be considered that the combination of technical solutions does not exist, and is not within the protection scope required by the present application.
[0060] Figure 1 An image credibility detection method provided by an embodiment of the present application is shown, and the method comprises:
[0061] Step 101: extracting visual features from a target image to be detected, wherein the visual features comprise color features, texture features and shape features;
[0062] Step 102: weighting and fusing the visual features and metadata features to obtain a fused feature vector; the metadata features represent image attribute information;
[0063] Step 103: calling a credibility detection model to detect the credibility of the target image according to the fused feature vector.
[0064] By extracting the color features, texture features and shape features of the target image, the visual content information of the image can be comprehensively captured. The color features can reflect the color distribution of the image, the texture features can capture the detailed texture of the image, and the shape features can describe the outline and shape of the objects in the image. These visual features reflect the visual characteristics of the image from different angles and provide rich information for subsequent credibility evaluation. The metadata features represent the attribute information of the image, such as shooting time, device model, geographical location, etc. These information provides the background information of image generation and source, which is helpful for evaluating the credibility of the image from the generation environment and condition. Weighting and fusing the visual features and metadata features can comprehensively consider the visual content and generation background of the image, so that the evaluation result is more comprehensive and accurate. Calling the trained credibility detection model to detect the credibility of the target image according to the fused feature vector. The model can recognize the mapping relationship between image features and credibility by learning a large number of image samples with labeled credibility, so as to accurately predict the credibility of new images. This machine learning-based method can automatically discover complex patterns in image features, improving the accuracy and reliability of evaluation.
[0065] In a possible implementation, before step 101, further comprising: receiving a target image and performing format processing and preprocessing; providing a basis for subsequent feature extraction and analysis. Only after the image is received and format processing and preprocessing are performed, it can be ensured that the image data meets the input requirements of the subsequent module, so that the subsequent feature extraction can be carried out smoothly. For example, the formats of images from different sources may be different, such as jpg, png, bmp, etc. Through format processing, they are unified into a format that can be processed by the system; the preprocessing steps such as removing noise and adjusting image size can help improve the accuracy and efficiency of subsequent feature extraction.
[0066] In a possible implementation, in step 101, visual features are extracted from the target image to be detected, including:
[0067] The target image is converted from an RGB color space to an HSV color space, and a color histogram is calculated to generate color features; the target image is converted into a grayscale image, and a gray-level co-occurrence matrix is calculated to extract texture feature statistics to generate texture features; edge detection and contour extraction are performed on the target image to generate shape features.
[0068] After the image is preprocessed, the visual features of the image are extracted next, including color features, texture features and shape features. These visual features reflect the visual content information of the image itself and are one of the important bases for evaluating the credibility of the image. Color features can reflect the color distribution of the image, texture features can reflect the texture details of the surface of objects in the image, and shape features can depict the contour shape and other information of objects in the image. These visual features provide data support for image content for the subsequent fusion with metadata features.
[0069] In a possible implementation, in step 101, a color histogram is calculated to generate color features, including: determining the number and range of quantization intervals for each channel in the HSV color space respectively; initializing a vector with a length of the sum of the quantization interval numbers of all channels according to the quantization interval numbers of the channels; starting from the first pixel of the target image, traversing each pixel in the target image row by row and column by column, obtaining the H, S and V values of the pixel in the HSV space; for the currently traversed pixel, calculating the index according to the H, S and V values in the HSV space and the quantization interval, and updating the count at the corresponding position; after traversing all pixels, the color features are obtained, representing the number of pixels in each quantization interval.
[0070] For an input RGB image, convert it to HSV color space using color space conversion formula or by means of functions in image processing libraries (such as OpenCV, etc.), to get the corresponding HSV image. For example, in OpenCV, the cvtColor function can be used, and the code example is I_HSV = cv2.cvtColor(I, cv2.COLOR_BGR2HSV), where I is the input RGB image, and I_HSV is the converted HSV image. Determine the number and range of quantization intervals for each channel (H, S, V) in the HSV color space. For example, the H channel is quantized into 36 intervals, and the S and V channels are quantized into 6 intervals, respectively. Specifically, the intervals can be divided equally according to the value range of each channel (the H channel is usually 0°-360°, and the S and V channels are usually 0-1 or 0-255, etc.). For example, for the H channel, if it is quantized into 36 intervals, the width of each interval is 360° / 36=10°, and the interval ranges are [0°,10°), [10°,20°),..., [350°,360°). According to the number of quantization intervals of each channel, initialize a vector with a length equal to the sum of the number of quantization intervals of all channels, and the initial value is 0. For example, the H channel has 36 intervals, and the S and V channels each have 6 intervals, so initialize a vector V_color with a length of 36+6+6=48, i.e. V_color = [0,0,...,0] (48 zeros in total).
[0071] Starting from the first pixel of the image, traverse each pixel in the image row by row and column by column. For each pixel, obtain its H, S, V values in the HSV space. For the currently traversed pixel, calculate its index position in the H, S, V channel quantization interval according to its H, S, V values. For example, for the H channel, if the H value of the pixel is 50° and the quantization interval is 10°, its index position is int(50 / 10)=5 (the index starts from 0). Then, add 1 to the value of the corresponding index position in the color feature vector V_color. Similarly for the S and V channels, calculate the index according to their values and quantization intervals, and update the corresponding position in V_color. After traversing all pixels, V_color is the final color feature vector, which contains the number of pixels in each quantization interval, reflecting the color distribution of the image in the HSV color space.
[0072] In one possible implementation, in step 101, the gray level co-occurrence matrix is calculated, and the texture feature statistics are extracted to generate the texture features, including:
[0073] initialize a gray level co-occurrence matrix according to a set gray level; start from a first pixel of the target image, traverse each pixel in the target image row by row and column by column; for each pixel, find a corresponding pixel pair according to a set distance and a set angle; obtain a gray level value of the currently traversed pixel pair, and add 1 to a value of a position in the gray level co-occurrence matrix; after traversing all the pixel pairs meeting the condition, the gray level co-occurrence matrix is constructed, and the gray level co-occurrence matrix represents a distribution of the pixel pairs in the target image at different gray levels; calculate a texture feature statistic quantity by using the gray level co-occurrence matrix, arrange the texture feature statistic quantity in order, and generate a texture feature.
[0074] For an input color image I, convert it to a gray image I_gray using functions or formulas in an image processing library (such as OpenCV, etc.). For example, in OpenCV, the cvtColor function can be used, and the code example is I_gray = cv2.cvtColor(I, cv2.COLOR_BGR2GRAY), where I is the input color image, and I_gray is the converted gray image. Create a matrix for counting the number of occurrences of pixel pair gray levels, and prepare a data structure for calculating texture feature statistics. According to the gray level L (for example, L = 256 represents the gray level range of 0-255), initialize a gray level co-occurrence matrix GLCM(d, θ) of size L × L, with initial value 0. Where d is the distance between pixel pairs, and θ is the direction. Start from the first pixel of the image, traverse each pixel in the image row by row and column by column. For each pixel, find the corresponding pixel pair according to the selected distance d and angle θ. For example, when d = 1 and θ = 0°, for the current pixel point (x, y), the corresponding pixel pair is (x + 1, y); when θ = 45°, the corresponding pixel pair is (x + 1, y + 1), and so on. Check the pixel pairs in the image one by one, count the number of occurrences of the pixel pairs meeting the condition at different gray levels, and fill the gray level co-occurrence matrix.
[0075] According to the gray level of the pixel pair, update the value of the corresponding position in the gray level co-occurrence matrix, and record the number of occurrences of the pixel pair at different gray levels. For the currently traversed pixel pair, obtain its gray level value (i, j). Then, add 1 to the value of position (i, j) in the gray level co-occurrence matrix GLCM(d, θ). After traversing all the pixel pairs meeting the condition, GLCM(d, θ) is the constructed gray level co-occurrence matrix, which reflects the distribution of pixel pairs in the image at different gray levels.
[0076] The statistical quantities capable of describing the texture features of the image, such as energy, contrast, correlation, entropy and the like, are extracted from the constructed gray level co-occurrence matrix, and are used for subsequent image analysis and processing. The calculated various texture feature statistical quantities are combined into a vector to form a feature vector for representing the texture features of the image, facilitating subsequent processing and analysis.
[0077] The optimal distance d and angle θ combination and whether to introduce the multi-scale gray level co-occurrence matrix can also be determined through experiments, so that the extracted texture features are more discriminative and representative, and the accuracy of subsequent image analysis is improved.
[0078] In a possible implementation, in step 101, the edge detection and contour extraction are performed on the target image to generate shape features, including:
[0079] The edge detection algorithm is used for edge detection on the target image to obtain an edge image; the contour extraction function is used to extract contours from the edge image; whether each extracted contour is a closed contour is judged; and the shape features of each closed contour are calculated, including the area of the region surrounded by the closed contour, the perimeter of the closed contour, the circularity, and the area of the minimum rectangle containing the closed contour; and all the shape features are combined into a vector as the shape features.
[0080] For the input image I, the Canny edge detection algorithm is used for edge detection. The contour extraction function, such as findContours, in the image processing library (such as OpenCV) is used to extract contours in the image from the obtained edge image I_edge. These contours can be the outer contours of objects or the hole contours inside the objects. For each extracted contour, analysis is performed to determine whether it is a closed contour, so as to calculate the shape features subsequently. For each closed contour, the shape features, such as the area, the perimeter, the circularity, the rectangularity and the like, are calculated, which can reflect the shape characteristics of the object and provide important information for image analysis and processing. The calculated various shape features are combined into a vector to form a feature vector for representing the shape features of the object, facilitating subsequent processing and analysis.
[0081] For objects with complex shapes, in addition to the basic shape features, higher-level shape analysis methods, such as shape context and Fourier descriptor, are introduced to more finely depict the shape features of the object and improve the discriminability and accuracy of the shape features in image credibility evaluation.
[0082] The extracted visual features and the parsed metadata features are fused to form a comprehensive feature vector. This step is the key link to organically combine the visual content information of the image and the generation source information. Through fusion, features of different dimensions can be integrated together to form a more comprehensive and richer feature representation, providing more powerful input data for the subsequent credibility assessment model. For example, color abnormalities in visual features may indicate that the image has been tampered with, and the mismatch between the camera model in the metadata and the imaging quality of the image content may also indicate that the image has problems. After fusing these information, the abnormal situation of the image can be more accurately captured, thereby improving the accuracy of the evaluation.
[0083] In a possible implementation, in step 103, the credibility detection model is called to detect the credibility of the target image according to the fused feature vector, including: inputting the fused feature vector into the credibility detection model, outputting a credibility score of the target image; and determining whether the target image is credible according to a set threshold and the credibility score.
[0084] The fused comprehensive feature vector is used to evaluate the credibility of the image through the trained model. The model is trained based on a large number of image samples with labeled credibility, and can learn the mapping relationship between image features and credibility. The fused feature vector is input into the model, and the model will score the credibility of the image according to the learned knowledge, and output a credibility score. This step is the core link of converting the features extracted and fused in the previous steps into specific credibility evaluation results, and the evaluation result of the model provides a quantitative basis for finally determining whether the image is credible. Finally, the credibility score of the image is output, and whether the image is credible is determined according to the set threshold. The setting of the threshold can be determined according to different application scenarios and requirements for credibility. By comparing the credibility score output by the model with the threshold, it can be directly concluded whether the image is credible. For example, if the score is greater than or equal to the threshold, the image is considered to be credible and can be used as a reliable information source; if the score is lower than the threshold, the image is considered to be not credible and may have been tampered with or have other problems, which needs to be treated with caution. This step is the end of the entire evaluation process, which converts the results of all previous steps into the final decision result, and provides a clear credibility judgment basis for various fields that rely on image information.
[0085] In a possible implementation, the credibility detection model is trained according to the following steps:
[0086] A number of image samples with labeled credibility are input into a credibility detection model to be trained, and the model parameters are initialized; the credibility detection model calculates the predicted credibility through forward propagation; the loss function value is calculated according to the predicted credibility and the labeled credibility; whether the condition for stopping training is reached is judged according to the loss function value, if the condition for stopping training is not met, the gradient is calculated through back propagation to update the model parameters; if the condition for stopping training is met, the trained credibility detection model is output.
[0087] The present application is dedicated to solving the core problem that the existing image credibility evaluation method is not accurate and comprehensive due to insufficient integration of image metadata and visual features. The visual features of the image are deeply fused with the metadata, thereby significantly improving the accuracy of image digital content credibility evaluation, and providing reliable evaluation means for various fields relying on image information.
[0088] Figure 2 The overall architecture of the image credibility evaluation system provided by the embodiments of the present application is shown, which includes:
[0089] Image input module: corresponding to the first stage, image acquisition and input. The system receives digital images from different sources and performs format processing and preprocessing.
[0090] Visual feature extraction module: corresponding to the second stage of visual feature extraction, including color, texture and shape feature extraction.
[0091] Metadata acquisition and analysis module: corresponding to the third stage, image metadata acquisition and analysis. The system reads and analyzes the metadata of the image, such as shooting time, device model, etc.
[0092] Feature fusion module: corresponding to the fourth stage of feature fusion and credibility evaluation model. The visual features and metadata features are fused to form a comprehensive feature vector.
[0093] Credibility evaluation model module: using the fused feature vector, the credibility of the image is evaluated by the trained model.
[0094] Evaluation result output: output the credibility score of the image, and judge whether the image is credible according to the set threshold.
[0095] The above-mentioned various stages are described in detail as follows.
[0096] First stage: image acquisition and input.
[0097] The digital image to be evaluated is obtained through image acquisition devices such as digital cameras, scanners, etc. or from the network, storage devices, etc. and input into the credibility evaluation system. The system performs uniform format processing and preprocessing on the input image to ensure that subsequent feature extraction and analysis can proceed smoothly.
[0098] Second stage: visual feature extraction:
[0099] Figure 3 The feature extraction process is shown. Color feature extraction: including RGB to HSV conversion (if needed), calculating color histogram, generating color feature vector. Texture feature extraction: converting the image to a grayscale image, calculating the gray level co-occurrence matrix, extracting texture feature statistics, and generating the texture feature vector. Shape feature extraction: edge detection, contour extraction, shape descriptor calculation, and shape feature vector generation.
[0100] First part: color feature extraction:
[0101] In the color feature extraction process, the image is converted from RGB color space to HSV color space (if needed), and then the color histogram is calculated. For each color channel, it is quantized into several intervals (such as the H channel quantized into 36 intervals, and the S and V channels quantized into 6 intervals respectively), and the number of pixels in each interval is counted to obtain the color feature vector. The specific operation is to traverse each pixel of the image, determine its belonging to the quantization interval according to its value in the HSV space, and then update the pixel count of the corresponding interval.
[0102] When performing color space conversion, in addition to considering the HSV space, other color spaces such as LAB can also be explored, and the effects of color feature extraction in different spaces are compared to further optimize the expression of color features. For example, the LAB color space is closer to human visual perception, and may better reflect color differences in certain image types.
[0103] Specifically, for the input digital image , it is converted from RGB color space to HSV color space (if color analysis is more advantageous in HSV space), obtaining the image . Let , , the number of quantization intervals of the three channels be , , respectively (for example, , , ). By calculating the color histogram , the number of pixels in each quantization interval is counted to obtain the color feature vector Color feature vector The calculation formula is as follows:
[0104]
[0105] Wherein, , , respectively represent , , The number of pixels in the first quantization interval in the channel.
[0106] Second part: texture feature extraction:
[0107] Convert the image to a grayscale image, and then calculate the gray level co-occurrence matrix. Select appropriate distance and angle parameters (such as distance 1, angle 0°, 45°, 90°, 135°), calculate the energy, contrast, correlation, entropy and other statistics of the gray level co-occurrence matrix as the texture features. For each selected distance and angle combination, the number of pixel pairs that meet the conditions in different gray levels is counted by traversing the pixel pairs in the image, thereby constructing the gray level co-occurrence matrix, and then calculating the texture feature statistics according to the corresponding formula.
[0108] The parameter selection of the gray level co-occurrence matrix has a great influence on the texture features. In addition to the commonly used distance 1 and angle 0°, 45°, 90°, 135° combination, other distance and angle combinations can also be tried, and the optimal parameter combination is determined through experiments. In addition, multi-scale gray level co-occurrence matrices can be introduced to capture image texture information from different scales, making the texture features more rich.
[0109] Specifically, first convert the image to a grayscale image . Let the gray level co-occurrence matrix be , where is the distance between pixel pairs (for example, ), and is the direction (take ). Calculate the energy , contrast , correlation , entropy and other statistics of the gray level co-occurrence matrix as the texture feature vector . Take the calculation formula of the energy as an example:
[0110]
[0111] Wherein, is the gray level.
[0112] Part Three: Shape Feature Extraction
[0113] Edge detection in images can be performed using algorithms such as Canny. Detected edges are then extracted and analyzed to calculate the object's shape features. For example, for closed contours, their area and perimeter are calculated, followed by shape descriptors such as roundness (4π × area / perimeter²). During edge detection, edge pixels are determined by calculating the image's gradient magnitude and direction. These edge pixels are then connected and thinned to obtain the object's contour. Based on the contour's coordinate information, parameters such as area and perimeter are calculated, thus determining the shape features.
[0114] For objects with complex shapes, in addition to calculating basic shape descriptors such as area, perimeter, and roundness, we can also consider introducing more advanced shape analysis methods, such as shape context and Fourier descriptors. These methods can more meticulously characterize the shape features of objects and improve the discriminative power of shape features in image credibility assessment.
[0115] Specifically, the Canny edge detection algorithm is used to analyze the image. Perform edge detection to obtain edge images. .right Contour extraction and analysis are performed for each closed contour. Calculate its area and perimeter Then calculate the roundness. (Formula for calculating roundness: degrees) = ), rectangularity (Formula for calculating rectangularity:) = ,in Shape descriptors such as the area of the smallest rectangle containing the contour are used to construct the shape feature vector. .
[0116] Phase 3: Image metadata acquisition and parsing
[0117] The metadata in the image file is read using a specialized metadata reading library. For the shooting time, it is converted from the original date-time format (e.g., "YYYY:MM:DD HH:MM:SS") to a timestamp. This process involves parsing the date-time string according to a specific format and then converting it to a timestamp value based on the timestamp calculation rules (e.g., seconds or milliseconds since a specific starting time). For the shooting device model, it is matched with a known device model database to obtain relevant information about the device (e.g., the device's brand, performance, etc.). By querying the database for the device model record, the corresponding brand and performance parameter information are obtained, which will be used as part of the metadata features for subsequent analysis.
[0118] Specifically, metadata is extracted from the image file , which follows the standard metadata format of the image file (e.g., EXIF format). The metadata includes but is not limited to the shooting time , the shooting device model , the geographic location information (if available), the creation time and modification time of the image file.
[0119] For the shooting time , it is converted from the original date-time format (e.g., "YYYY:MM:DD HH:MM:SS") to a timestamp for comparison and analysis with other time-related data. For the shooting device model, it is matched with a known device model database to obtain the device's brand , performance parameters , and other relevant information.
[0120] Fourth stage: Feature fusion and credibility evaluation model:
[0121] The extracted visual features and metadata features are fused according to the predetermined fusion method (e.g., weighted fusion). The fused feature vector is input into the trained credibility evaluation model, and the model outputs the credibility score of the image (e.g., a value between 0 and 1, 0 indicating completely unreliable and 1 indicating completely reliable). According to the set threshold (e.g., 0.5), it is determined whether the image is reliable. If the score is greater than or equal to the threshold, the image is considered reliable; otherwise, it is considered unreliable. In practical applications, the threshold can be adjusted according to different scenarios and requirements. In the feature fusion process, the elements of the visual feature vector and the metadata feature vector are weighted and summed according to the set weights. For the credibility evaluation model, the fused feature vector is input, and the credibility score is obtained through the internal calculation of the model (e.g., the forward propagation process of the neural network).
[0122] Specifically, the feature fusion: the extracted visual feature vector and the parsed metadata feature vector are fused. A weighted fusion method is adopted, and the visual feature weight vector is (e.g. , , ), the metadata feature weight vector is (e.g. , , , , , ), and the fused feature vector is calculated as follows:
[0123]
[0124] The credibility evaluation model: use machine learning algorithms (such as support vector machines, neural networks, etc.) to build a credibility evaluation model. Use a large number of labeled image samples (where , 0 represents untrustworthy, and 1 represents trustworthy) to train the model. In the training process, the parameters of the model are adjusted by minimizing the loss function (such as cross-entropy loss function). The trained model is used to evaluate the new fused feature vector , and outputs the credibility score of the image. The calculation formula can be expressed as: .
[0125] According to the set threshold (e.g. ), it is judged whether the image is trustworthy. If S , the image is considered trustworthy; otherwise, the image is considered untrustworthy.
[0126] Figure 4 The training process of the credibility evaluation model is shown in the following figure:
[0127] Step 1: Input labeled image samples: input image samples with labels.
[0128] Step 2: Model structure initialization: initialize model parameters.
[0129] Step 3: Forward propagation to calculate the predicted credibility: calculate the predicted credibility of the input image by the model.
[0130] Step 4: Calculate the loss function: calculate the loss according to the predicted result and the true label.
[0131] Step 5: Determine if the stopping condition is met: Check if the condition for stopping training is met.
[0132] Step 6: Backpropagation to calculate gradient: If the stopping condition is not met, perform backpropagation to calculate the gradient. Update the model parameters based on the gradient: Update the model parameters.
[0133] Step 7: Training is complete, output the trained model: When the stopping condition is met, output the trained model.
[0134] By fusing visual features and metadata, the content information of the image itself and its source, and related information are fully utilized, forming a multi-dimensional evaluation perspective. This multi-dimensional evaluation method can more comprehensively analyze the image and reduce misjudgment caused by a single information source. For example, for an image that has been partially tampered with, it may not be possible to discover subtle changes through visual features alone, but combining metadata information (such as the mismatch between the shooting device and the imaging quality of the objects in the image content) can discover abnormalities, thereby improving the accuracy of image credibility evaluation.
[0135] The present application can adapt to various types of images, whether they are natural scenery images, portrait photos, identification images, or images that have been processed (such as scanned document images), and can be evaluated for credibility by extracting and fusing relevant features. Different types of images have their own characteristics in visual features and metadata, and the present method can effectively extract and fuse features based on these characteristics, making it widely applicable.
[0136] For tampered images, there may be inconsistencies between their visual features and metadata. For example, a tampered image may have abnormalities in color and texture, while its metadata information such as shooting time and device may not match the image content. The present application can effectively identify such inconsistencies through joint analysis of visual features and metadata, thereby accurately judging the credibility of the image. This capability is of great significance in fields such as law enforcement and journalism, where image authenticity is highly valued.
[0137] In medical diagnosis, the credibility of images is crucial. The present application can be applied to the credibility evaluation of medical images such as X-rays, CT scans, and MRIs. For example, for some fake or tampered medical images, by analyzing their visual features and metadata such as imaging device model and imaging time, abnormalities can be discovered in a timely manner, avoiding misdiagnosis and ensuring patient health and medical safety.
[0138] On e-commerce platforms, the credibility of product pictures directly affects consumers' purchasing decisions. By using the application to evaluate product pictures, false pictures that have been maliciously tampered with or exaggerated can be screened out, thereby maintaining the reputation of e-commerce platforms and the legitimate rights and interests of consumers. For example, for some PS-processed clothing pictures, the consistency of their visual features such as texture and shape with metadata such as shooting device and shooting time can be analyzed to determine whether the pictures are authentic and reliable.
[0139] With the development of online education, teaching resources contain a large amount of image data. Evaluating the credibility of these images can ensure the authenticity and accuracy of teaching content. For example, for historical relic pictures and scientific experiment pictures, their credibility can be evaluated by the application to avoid misleading students with false information and improve the teaching quality of online education.
[0140] In summary, the embodiments of the present application provide an image credibility detection method, which extracts visual features from a target image to be detected, the visual features including color features, texture features and shape features; the visual features are weighted and fused with metadata features to obtain a fused feature vector; the metadata features represent image attribute information; a credibility detection model is called to detect the credibility of the target image according to the fused feature vector. By extracting visual features and metadata features of the target image, weighting and fusing, and then using the trained credibility detection model for evaluation, the accuracy of image credibility evaluation is improved, comprehensive evaluation means are provided, and the reliability and practicality of evaluation are enhanced. This method can effectively deal with various complex scenarios and provide reliable evaluation means for various fields that rely on image information.
[0141] Based on the same technical concept, the embodiments of the present application also provide an image credibility detection system, as shown in Figure 5 The system comprises:
[0142] A feature extraction module 501 is configured to extract visual features from a target image to be detected, the visual features including color features, texture features and shape features;
[0143] A feature fusion module 502 is configured to weight and fuse the visual features with metadata features to obtain a fused feature vector; the metadata features represent image attribute information;
[0144] A credibility detection module 503 is configured to call a credibility detection model to detect the credibility of the target image according to the fused feature vector.
[0145] The present application also provides an electronic device corresponding to the method provided in the preceding embodiments. Please refer to Figure 6Fig. 2 shows an electronic device diagram provided by some embodiments of the present application. The electronic device 20 can include a processor 200, a memory 201, a bus 202, and a communication interface 203, which are connected through the bus 202. The memory 201 stores a computer program executable on the processor 200. The processor 200 executes the computer program to perform the method provided by any of the preceding embodiments of the present application.
[0146] The memory 201 can include a high-speed random access memory (RAM) and can also include a non-volatile memory such as at least one disk memory. The communication connection between the system network element and at least one other network element is achieved through at least one physical port (which can be wired or wireless) and can use the Internet, a wide area network, a local network, a metropolitan area network, etc.
[0147] The bus 202 can be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The memory 201 is used to store programs, and the processor 200 executes the programs after receiving execution instructions. The method disclosed in any of the preceding embodiments of the present application can be applied to the processor 200 or implemented by the processor 200.
[0148] The processor 200 can be an integrated circuit chip with signal processing capability. In the implementation process, each step of the above method can be completed by integrated logic circuits or instructions in the form of software in the processor 200. The processor 200 described above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a ready-to-program gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. mature storage media in the art. The storage medium is located in the memory 201, and the processor 200 reads the information in the memory 201, and combines its hardware to complete the steps of the above method.
[0149] The electronic device provided by the embodiments of the present application and the method provided by the embodiments of the present application have the same beneficial effects as the method they adopt, run or implement.
[0150] The embodiments of the present application also provide a computer readable storage medium corresponding to the method provided by the foregoing embodiments, please refer to Figure 7 The computer readable storage medium shown in the figure is an optical disc 30, and a computer program (i.e. a program product) is stored on the optical disc 30. When the computer program is run by a processor, the method provided by any of the foregoing embodiments is executed.
[0151] The above merely provides the preferred embodiments of the present application, and does not limit the patent scope of the present application. Any equivalent structure transformation made under the concept of the present application, or direct / indirect application in other related technical fields by using the content of the present application specification and drawings is included in the patent protection scope of the present application.
Claims
1. An image trustworthiness detection method, characterized in that, The method comprises: extracting visual features from a target image to be detected, the visual features including color features, texture features and shape features; weighting and fusing the visual features and metadata features to obtain a fused feature vector; the metadata features represent image attribute information; calling a credibility detection model to detect the credibility of the target image according to the fused feature vector; extracting visual features from a target image to be detected, comprising: converting the target image from an RGB color space to an HSV color space, and calculating a color histogram to generate color features; converting the target image into a grayscale image, calculating a gray level co-occurrence matrix, and extracting texture feature statistics to generate texture features; performing edge detection and contour extraction on the target image to generate shape features; calculating a color histogram to generate color features, comprising: determining the number and range of quantization intervals for each channel in the HSV color space; initializing a vector with a length equal to the sum of the quantization interval numbers of all channels according to the quantization interval numbers of each channel; starting from the first pixel of the target image, traversing each pixel in the target image row by row and column by column to obtain the H, S and V values of the pixel in the HSV space; for the currently traversed pixel, calculating an index according to the H, S and V values in the HSV space and the quantization interval, and updating the count at the corresponding position; after traversing all pixels, obtaining color features representing the number of pixels in each quantization interval; the calculation of the gray level co-occurrence matrix and the extraction of texture feature statistics to generate texture features, comprising: initializing a gray level co-occurrence matrix according to a set gray level; starting from the first pixel of the target image, traversing each pixel in the target image row by row and column by column; for each pixel, finding a corresponding pixel pair according to a set distance and a set angle, obtaining the gray level values of the currently traversed pixel pair, and adding 1 to the value of the position in the gray level co-occurrence matrix; after traversing all the pixel pairs that meet the conditions, the gray level co-occurrence matrix is constructed, and the gray level co-occurrence matrix represents the distribution of pixel pairs in different gray levels in the target image; using the gray level co-occurrence matrix to calculate texture feature statistics, arranging the texture feature statistics in order to generate texture features.
2. The method of claim 1, wherein, the edge detection and contour extraction on the target image to generate shape features, comprising: using an edge detection algorithm on the target image to perform edge detection and obtain an edge image; using a contour extraction function to extract contours from the edge image; for each extracted contour, determining whether it is a closed contour; calculating the shape features of each closed contour, the shape features including the area of the region enclosed by the closed contour, the perimeter of the closed contour, the circularity, and the area of the smallest rectangle containing the closed contour; combining all the shape features into a vector as the shape features.
3. The method of claim 1, wherein, the calling of the credibility detection model to detect the credibility of the target image according to the fused feature vector, comprising: inputting the fused feature vector into the credibility detection model to output a credibility score of the target image. Determine whether the target image is reliable according to the set threshold and the reliability score.
4. The method of claim 3, wherein, The reliability detection model is trained according to the following steps: A plurality of image samples with labeled reliability are input into the reliability detection model to be trained, and the model parameters are initialized; The reliability detection model calculates the predicted reliability through forward propagation; A loss function value is calculated according to the predicted reliability and the labeled reliability; It is determined whether the condition for stopping training is met according to the loss function value, and if the condition for stopping training is not met, the gradient is calculated through back propagation to update the model parameters; If the condition for stopping training is met, the trained reliability detection model is output.
5. An image trustworthiness detection system, characterized by, The system comprises: A feature extraction module for extracting visual features from a target image to be detected, the visual features including color features, texture features and shape features; A feature fusion module for weighting and fusing the visual features and metadata features to obtain a fused feature vector; the metadata features represent image attribute information; A reliability detection module for calling a reliability detection model to detect the reliability of the target image according to the fused feature vector; The visual features are extracted from the target image to be detected, including: The target image is converted from an RGB color space to an HSV color space, and a color histogram is calculated to generate color features; The target image is converted into a grayscale image, and a gray level co-occurrence matrix is calculated to extract texture feature statistics and generate texture features; Edge detection and contour extraction are performed on the target image to generate shape features; The color histogram is calculated to generate color features, including: The number and range of quantization intervals are determined for each channel in the HSV color space; According to the number of quantization intervals of each channel, a vector with a length equal to the sum of the number of quantization intervals of all channels is initialized; Starting from the first pixel of the target image, each pixel in the target image is traversed row by row and column by column to obtain the H, S and V values of the pixel in the HSV space; For the currently traversed pixel, the index is calculated according to the H, S and V values in the HSV space and the quantization interval, and the corresponding position is updated; After traversing all pixels, the color features are obtained, representing the number of pixels in each quantization interval; The gray level co-occurrence matrix is calculated to extract texture feature statistics to generate texture features, including: A gray level co-occurrence matrix is initialized according to a set gray level; Starting from the first pixel of the target image, each pixel in the target image is traversed row by row and column by column; For each pixel, a pixel pair corresponding to it is found according to a set distance and a set angle; the gray level values of the currently traversed pixel pair are obtained, and the value of the position in the gray level co-occurrence matrix is incremented by 1; After traversing all the pixel pairs that meet the conditions, the gray level co-occurrence matrix is constructed, and the gray level co-occurrence matrix represents the distribution of pixel pairs in different gray levels in the target image; The texture feature statistics are calculated using the gray level co-occurrence matrix, and the texture feature statistics are arranged in order to generate texture features.
6. An electronic device comprising: A memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that the processor, when executing the computer program, performs to implement the method of any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, A computer program product having stored thereon computer readable instructions executable by a processor to implement the method of any one of claims 1-4.
Citation Information
Patent Citations
Tamper detection method and device, equipment, storage medium and product
CN118587462A