i m doing image enhancement using a transformation function.i need help in the coding.I have considered the (3,4)pixel value

1 次查看(过去 30 天)
clear all;
close all;
input1=imread('cameraman.tif');
subplot(2,1,1),imshow(input1)
C=mean2(double(input1))%global mean
slidingmean=conv2(double(input1),ones(3)/9,'same');%local mean over 3 by 3 window
%figure(2),imshow(slidingmean)
J=stdfilt(input1);%standard deviation of the 3 by 3 neighborhood
figure(2),imshow(J,[])
a=1;b=.5;c=1;k=1.5;
K=(k*C)./(2.2423+b)
g=K*(157-(c*156.4444))+(156.4444).^a;%the transformation function
outpu1=g(input1);
figure(3),imshow(output1)

采纳的回答

Image Analyst
Image Analyst 2013-9-12
Yeah, the 3,4 pixel - that one is always the troublemaker isn't he?
But since you didn't share your error message with us, I'm going to assume that it referred to output1 not being known. So try outpu1 instead of output1 and see if that works. Or else change outpu1 to output1 - either way should fix that error.
  5 个评论
Image Analyst
Image Analyst 2013-9-13
No you didn't. Your first comment gave only the line number and code on that line but did not give the actual error message description like you did in the second case.
You can't combine input, which is an integer with doubles. So case input to double before combining. Here, I fixed it for you and made some other improvements though you shoudl really go through and make descriptive variable names, not things like C, J, etc.
clear all;
close all;
input1=imread('pout.tif');
subplot(2,2,1);
imshow(input1);
C=mean2(double(input1))%global mean
caption = sprintf('input1, Global Mean = %2.f', C);
title(caption, 'FontSize', 25);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
slidingmean=conv2(double(input1),ones(3)/9,'same');%local mean over 3 by 3 window
%figure(2),imshow(slidingmean)
J=stdfilt(input1);%standard deviation of the 3 by 3 neighborhood
subplot(2,2,2);
imshow(J,[])
title('The (badly-named) J', 'FontSize', 25);
% Do a transform of some sort.
a=1;
b=.5;
c=1;
k=1.5;
K=(k.*C)./(J+b);
g=K.*(double(input1)-(c.*slidingmean))+(slidingmean).^a;%the transformation
output1=g.*double(input1);
% output1 displayed linearly will be very hard to see.
subplot(2,2,3);
imshow(output1, []);
title('output1', 'FontSize', 25);
% Apply a log transform to output1 so we can see it better.
subplot(2,2,4);
imshow(log(output1), []);
title('log(output1)', 'FontSize', 25);
Even the improvements I made wouldn't make it up to the level of robustness required my company for an app that is to be used by other people.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by