Clear Filters
Clear Filters

How do i generate hash value from an image file ?

14 views (last 30 days)
Hi, I'm writing a project which involves the generation of MD5 Hash values from an image, i have analysed the image using MATLAB. I have also gotten to the point of finding a ROI (Region of Interest) but i dont know how i can be able to generate hash values from there.
Please any help will be appreciated.
this is the code i have so far..
clear all;
k=input ('Enter the file name:' , 's');
I = imread(k);
background = imopen(I,strel('disk',15));
figure, surf(double(background(1:8:end,1:8:end))),zlim([0 255]);
set(gca,'ydir','reverse');
I2 = I - background;
I3 = imadjust(I2);
level = graythresh(I3);
bw = im2bw(I3,level);
bw = bwareaopen(bw, 50);
I4 = imshow(I);
e = imellipse(gca,[65 109 48 48]);
BW = createMask(e,I4);
img = double(I4);
[SP_POINTS] = MakeFeatures(img);
%Show feature points
out = 1- SP_POINTS;
out = im2uint8(out);
hashVec = createstruct(out);
figure, imshow(I);
figure, imshow(I2);
figure, imshow(I3);
figure, imshow(bw);
cc = bwconncomp(bw, 4)
cc.NumObjects
  1 Comment
Institute Jassim
Institute Jassim on 24 Aug 2012
Hi Freind, I am wotking on the watermarking by using wavelet algorith. I need to create a hash function in matlab language for an image in order to embed it as a watermark.

Sign in to comment.

Answers (3)

Jan
Jan on 17 Mar 2011
There are some tools in the FEX: computehash, CalcMD5

Walter Roberson
Walter Roberson on 17 Mar 2011
imshow() returns the handle-graphics handle to the image object created in the tool figure. A handle-graphics handle is already of class double, so I am having difficulty figuring out what you are expecting your line
img = double(I4);
to do ?
MakeFeatures does not appear to be a Mathworks routine, and createstruct() does not appear to be either.
If you were to use
roiPixels = I(repmat(logical(BW),1,1,size(I,3)));
then that would extract the pixel values only at the masked locations. Be careful, though: if your original image is RGB then all of the information for R would appear before all of the information for G which in turn would appear before all of the information for B.

shivu P
shivu P on 23 Mar 2018
Edited: Walter Roberson on 26 Mar 2018
Enter the file name:c.jpg
Undefined function 'MakeFeatures' for input arguments of type 'double'.
Error in MD5 (line 25) [SP_POINTS] = MakeFeatures(img); >> >>
I am getting this error after executing this code..........any help to resole this would be more appreciable

Community Treasure Hunt

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

Start Hunting!