How the difference(difference of adjacent pixel values) histogram of an image can be plot ?I want to generate a difference image and histogram of thedifference image.I have write a code,but getting an error.Please help.
Afficher commentaires plus anciens
clc;
clear all;
close all hidden;
[file,path]=uigetfile('*.bmp;*.jpg','Pick an Image File');
if isequal(file,0) isequal(path,0) warndlg('User Pressed Cancel'); else Host_im=imread(file);
[r c p] = size(Host_im);
if p==3
Host_im = rgb2gray(Host_im);
end
figure(1);
imshow(Host_im);
title('Input Image');
end
X = inputdlg('Enter Value from 0 to 5');
L = str2num(X{1});
P = 2^L;
H = Host_im;
figure(2);
imhist(Host_im);
title('Histogram of Input Image(Fused Image)');
xlabel('Pixel value');
ylabel('No of pixels');
%%%%%%%%Histogram Shifting
location1 = find(Host_im<P);
location2 = find(Host_im>(255-P));
H(location1)=H(location1)+P;
H(location2)=H(location2)-P;
figure(3);
imshow(H,[]);
title('Image of Histogram Shifted Image');
figure(4);
imhist(H);
title('Histogram of Histogram Shifted Image');
xlabel('Pixel value');
ylabel('No of pixels');
%%%%%%To find pixel difference
Host_im = double(Host_im);
Row = r;
Col = c;
k =1;
for i = 1:Row
im_val = Host_im(i,:);
if mod(i,2)==0 %%%%%%%%%%checkreminder
d(k:i*Col,:) = im_val(end:-1:1)';
else
d(k:i*Col,:) = im_val(1:1:end)';
end
k = i*Col + 1;
end
Diff(1) = d(1);
Diff(2:length(d)) = abs(d(1:length(d)-1) - d(2:length(d)));
x = d; len = length(Diff); Row = r; Col =c; k =1; for i = 1:Row if mod(i,2)==0 star_p = Col; mid_p = -1; end_p = 1; else star_p = 1; mid_p = 1; end_p = Col; end for j = star_p:mid_p:end_p nw(i,j) = Diff(k); k = k+1; end end location14 = find(nw<P); location15 = find(nw>(255-P));
nw(location14)=nw(location14)+P; nw(location15)=nw(location15)-P;
figure(35);
imshow(nw,[]);
title('Image of difference Histogram Shifted Image');
figure(45);
imhist(nw);
[counts x]=imhist(nw)
title('Histogram of difference Histogram Shifted Image');
xlabel('Pixel value');
ylabel('No of pixels');
2 commentaires
Geoff Hayes
le 9 Juin 2014
Rather than pasting your code (some of which is formatted and some of which isn't), it would be simpler to just attach the file to your question (or any subsequent comment that you make) - use the paperclip icon to do so.
As well, you did not include the error message….
ATHIRA
le 10 Juin 2014
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Histograms dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!