필터 지우기
필터 지우기

Image authentication using color information

조회 수: 1 (최근 30일)
Devarshi Patel
Devarshi Patel 2018년 12월 3일
답변: Devarshi Patel 2018년 12월 19일
I am using attached script for splitting the image into 21 blocks (for Red, Green and Blue channels) and then compare each block pixel by pixel.
However, I want to do some changes as below:
1) How can I divide the image automatically into n number of equal blocks ( so I will just have to say 10 and it will divide the image into 10 equal size blocks).
2) I used isequal() function for comparison two blocks. How can I get the distance between two blocks. (Like Euclidean distance or something)
3) How to compare RGB histogram for each block. (Here I think it is possible to only compare the Y axis as X axis of the histogram will be 0 to 255 for all the blocks.) I know how to generate histogram but I dont know how to use that information for the comparison.
4) How can I keep some threshold e.g after comparison if all the blocks are matching > 98% then it is a true image OTW false image detected.
Thank you in advance.
  댓글 수: 11
Devarshi Patel
Devarshi Patel 2018년 12월 10일
I removed the paper. Can you please help me with modifying the code that you suggested for histogram comparison? As I tried to get histogram of the sub image blocks but couldn't do it. Please help me with this.
Devarshi Patel
Devarshi Patel 2018년 12월 10일
편집: Devarshi Patel 2018년 12월 10일
If you dont have enough time can you at least show me how to get the histogram of each block in blocks 1 and blocks 2 generated by:
clear
clc
%inputs:
% img: an image (2D or 3D numeric array)
% M, N: the number of blocks along the rows, columns respectively
%output:
% block: a M x N cell array of 2D or 3D numeric arrays
img1 = imread('w.png');
M = 3;
N = 7;
blocks1 = mat2cell(img1, ones(1, M) * size(img1, 1) / M, ones(1, N) * size(img1, 2) / N, size(img1, 3)); %will error if M and N are not divisors of H and W
% second image
img2 = imread('b.png');
M1 = 3;
N1 = 7;
blocks2 = mat2cell(img2, ones(1, M1) * size(img2, 1) / M1, ones(1, N1) * size(img2, 2) / N1, size(img2, 3)); %will error if M and N are not divisors of H and W
%inputs:
% blocks1: blocks of 1st image. M x N cell array of 2D or 3D numeric arrays
% blocks2: blocks of 2nd image. Same size as blocks1
%outputs:
% comparison: a M X N double array of euclidean distance between each matching block.
comparison = cellfun(@(b1, b2) sqrt(sum((b1(:) - b2(:)) .^2)), blocks1, blocks2)
This will be very helpful Please help me with this.

댓글을 달려면 로그인하십시오.

채택된 답변

Guillaume
Guillaume 2018년 12월 4일
1. Dividing an image of size HxW into MxN blocks where M and N are divisors of H and W respectively:
%inputs:
% img: an image (2D or 3D numeric array)
% M, N: the number of blocks along the rows, columns respectively
%output:
% block: a M x N cell array of 2D or 3D numeric arrays
blocks = mat2cell(img, ones(1, M) * size(img, 1) / M, ones(1, N) * size(img, 2) / N, size(img, 3)); %will error if M and N are not divisors of H and W
2. It seems to me that you haven't defined your comparison metric. You probably need to do some research on what it should be. Once you've defined that, it's easy to perform the comparison. Here, I'm using the square root of the sum of the square of the differences between corresponding pixels of each block. I have no idea if it is a good metric, as it's not my field:
%inputs:
% blocks1: blocks of 1st image. M x N cell array of 2D or 3D numeric arrays
% blocks2: blocks of 2nd image. Same size as blocks1
%outputs:
% comparison: a M X N double array of euclidean distance between each matching block.
comparison = cellfun(@b1, b2) sqrt(sum((b1(:) - b2(:)) .^2)), blocks1, blocks2)
3. Again, making the comparison is trivial but you need to define a metric first.
  댓글 수: 11
Guillaume
Guillaume 2018년 12월 6일
As I said it's not my domain. However, I'm sure you can find plenty of reliable methods in the plethora of papers that have been written on the subject.
Devarshi Patel
Devarshi Patel 2018년 12월 6일
I will go through some papers for that.
Another thing I am confuse about is how is euclidean distance formula "comparison = cellfun(@(b1, b2) sqrt(sum((b1(:) - b2(:)) .^2)), blocks1, blocks2)" is working in my case as each pixel has 3 value (R,G and B) specifically how it is taking the diffrence and coming up with the single number. Maybe it is sill question but I am not understanding it. I tried going through the cellfun discription. Any explanation will be appreciated.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Image Analyst
Image Analyst 2018년 12월 7일
Maybe you should just try ro register the images with imregister() and then use immse() and ssim().
Or you could also use Hu's moments
Or any of the feature matching things in the Computer Vision System Toolbox.
  댓글 수: 3
Image Analyst
Image Analyst 2018년 12월 7일
There are so very many things that could possibly be measured. For one, you could just compute the RGB histograms of each image. Better, why don't you look up forgery or forensics in VisionBibliography and you'll find lots of algorithms. Pick one or two and code them up:
Devarshi Patel
Devarshi Patel 2018년 12월 7일
I tried looking into few papers but none of them are helpful for writing a MATLAB code (may be because I am new and know very little coding). I will investigate it more. Thank you for your suggestion.If any particular code (which considers colors as well as structural features for image comparison) comes to your mind please let me know as database have thousands of papers.

댓글을 달려면 로그인하십시오.


Devarshi Patel
Devarshi Patel 2018년 12월 19일
Hi Guillaume & Image Analyst,
Thank you for your answers so far I have just last question after that I will Accept the answer. Attached images are same images and taken in same condition but still when you compare 2 images it shows larger distance. Can you give me any suggestions how to solve this ? Is there any way of preprocessing to match the images? like thresholding or removing the noise or something similar

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by