[問題] 為什麼圖片會紅紅綠的已回收
我處理過的圖片 放到pair_comp裡
會有紅紅綠綠的
要怎麼解決?
下面是我用的到程式碼
這是處理圖片的程式
for i=1:5;
for cc=0:0.075:0.5 ;
A=imread(strcat(num2str(i),'.tif')); %可以不用A=[[A]./2.55];
B=repmat((mean(mean(A))),[size(A,1),size(A,2),1]);
c=1+cc; %改變的對比值
img2=(double(A)-B)*c+B;
s2=std(std(img2));
ma=mean(mean(A));
m2=mean(mean(img2));
imshow(uint8(img2))
imwrite(uint8(img2),strcat('20080930easylc',[num2str(i),'-',num2str(c),'.tif'])
,'tif','ColorSpace','cielab');
end
end
這是pair_comp的主程式
%GUI for pair comparison image experiment
function varargout = pair_comp_test(varargin)
% PAIR_COMP_TEST M-file for pair_comp_test.fig
% Last Modified by GUIDE v2.5 30-Sep-2008 00:01:34
% Written by P.L. Sun
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @pair_comp_test_OpeningFcn, ...
'gui_OutputFcn', @pair_comp_test_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before pair_comp_test is made visible.
function pair_comp_test_OpeningFcn(hObject, eventdata, handles, varargin)
clc, warning off
set([handles.axes1 handles.axes2 handles.betterBtn1 handles.betterBtn2
handles.undoBtn], 'visible', 'off')
axes(handles.axes3)
imshow(imread('pairCompInstruction.tif'))
if exist('pairCompData.mat') == 0
maxObsNo = 30;
score3 = logical(zeros(3,3,maxObsNo));
score4 = logical(zeros(4,4,maxObsNo));
score5 = logical(zeros(5,5,maxObsNo));
score6 = logical(zeros(6,6,maxObsNo));
score7 = logical(zeros(7,7,maxObsNo));
score8 = logical(zeros(8,8,maxObsNo));
score9 = logical(zeros(9,9,maxObsNo));
score10 = logical(zeros(10,10,maxObsNo));
save pairCompData.mat score3 score4 score5 score6 score7 score8 score9
score10
end
handles.output = hObject;
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = pair_comp_test_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'));
set(hObject,'BackgroundColor','white');end
function edit2_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');end
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');end
% --- Executes on button press in StartBtn.
function StartBtn_Callback(hObject, eventdata, handles)
handles.obsNo = str2num(get(handles.edit1, 'string'));
handles.imgNo = str2num(get(handles.edit2, 'string'));
n=0;
for x=1:handles.imgNo-1
for y=x+1:handles.imgNo
n=n+1;
handles.orgSequence(n,1) = x;
handles.orgSequence(n,2) = y;
end
end
handles.totalPairs = n;
handles.a = randperm(n);
handles.scoreObs = zeros(handles.imgNo);
bk = get(handles.popupmenu1, 'value');
set(gcf,'color',[(bk-1)/2 (bk-1)/2 (bk-1)/2])
axes(handles.axes3)
bkImg = ones(1,1,3);
bkImg(1,1,:) = (bk-1)/2*255;
imshow(uint8(bkImg))
set([handles.text1 handles.text2 handles.edit1 handles.edit2
handles.popupmenu1 handles.StartBtn], 'visible', 'off')
set([handles.axes1 handles.axes2 handles.betterBtn1 handles.betterBtn2
handles.undoBtn], 'visible', 'on')
handles.seq = 1;
guidata(hObject, handles);
showImagePair_Callback(hObject, handles)
% --- Executes on button press in betterBtn1.
function betterBtn1_Callback(hObject, eventdata, handles)
%save current data
fprintf(' L\n')
handles.scoreObs(handles.imgID2, handles.imgID1) = 1;
%show next image pair
if handles.seq < handles.totalPairs
handles.seq = handles.seq + 1;
guidata(hObject, handles);
showImagePair_Callback(hObject, handles)
else
saveData_Callback(hObject, handles)
end
% --- Executes on button press in betterBtn2.
function betterBtn2_Callback(hObject, eventdata, handles)
%save current data
fprintf(' R\n')
handles.scoreObs(handles.imgID1, handles.imgID2) = 1;
%show next image pair
if handles.seq < handles.totalPairs
handles.seq = handles.seq + 1;
guidata(hObject, handles);
showImagePair_Callback(hObject, handles)
else
saveData_Callback(hObject, handles)
end
% --- Executes on button press in undoBtn.
function undoBtn_Callback(hObject, eventdata, handles)
handles.seq = handles.seq - 1;
if handles.seq < 1; handles.seq = 1; end
guidata(hObject, handles);
fprintf(' Undo\n')
showImagePair_Callback(hObject, handles)
% --- Sub-function for betterBtn1, betterBtn2 and undoBtn.
function showImagePair_Callback(hObject, handles)
k = handles.a(handles.seq);
if rand()>0.5
handles.imgID1 = handles.orgSequence(k,1);
handles.imgID2 = handles.orgSequence(k,2);
else
handles.imgID1 = handles.orgSequence(k,2);
handles.imgID2 = handles.orgSequence(k,1);
end
guidata(hObject, handles);
fprintf('[%d] %d vs. %d ', handles.seq, handles.imgID1, handles.imgID2)
axes(handles.axes1)
imshow([int2str(handles.imgID1) '.tif'])
axes(handles.axes2)
imshow([int2str(handles.imgID2) '.tif'])
% --- Sub-function for betterBtn1 and betterBtn2.
function saveData_Callback(hObject, handles)
load pairCompData
scoreObs = handles.scoreObs;
fprintf('\n')
disp('this observer:')
disp(scoreObs)
switch handles.imgNo
case 3
score3(:,:,handles.obsNo) = scoreObs; newScore = score3;
case 4
score4(:,:,handles.obsNo) = scoreObs; newScore = score4;
case 5
score5(:,:,handles.obsNo) = scoreObs; newScore = score5;
case 6
score6(:,:,handles.obsNo) = scoreObs; newScore = score6;
case 7
score7(:,:,handles.obsNo) = scoreObs; newScore = score7;
case 8
score8(:,:,handles.obsNo) = scoreObs; newScore = score8;
case 9
score9(:,:,handles.obsNo) = scoreObs; newScore = score9;
case 10
score10(:,:,handles.obsNo) = scoreObs; newScore = score10;
end
save pairCompData.mat score3 score4 score5 score6 score7 score8 score9
score10 -append
msgbox({'Thank you for your contribution.';'See "pairCompData.mat"';'for the
data'},'Complete!','help')
uiwait
close
M=sum(newScore, 3);
disp('all observers:')
disp(M)
figure
paircomp_data(M);
xlabel('images'), ylabel('z-score'), set(gcf,'color','w')
這是心理物理的程式
function [S,b,u]=catjudge(scores,tdist)
% CATJUDGE: calculates interval scale from category judgement data
% applying Torgerson's Law of Category Judgement (Case D)
% and using method described in:
% Engledrum, P. 'Psychometric Scaling', Imcotek Press, 2000, pp131-134.
%
% Output data are interval scale scores, category boundaries and
% 95% confidence interval.
%
% Example: [S,b,c]=catjudge(K)
% where K is an n by m matrix, whose rows correspond to the samples,
% whose columns correspond to the categories, and whose data is the
% frequency with which a given judgement category was selected by
% observers for each sample.
%
% Use plotcaterror.m to plot resulting interval scores
% with confidence intervals and category boundaries.
%
% The confidence interval is determined using the Student's t
% distribution to estimate the population standard deviation
% from the sample standard deviation. If the switch 0 is used,
% the sample standard deviation is used instead.
% Example: [S,b,c]=catjudge(K,0)
%
% Colour Engineering Toolbox
% author: catjudge(scores,tdist)
貼不下了 我的msn是soiialan@hotmail.com
EMAIL是soiipopoalan@yahoo.com.tw
soiialan@gmail.com
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.137.51.45
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章