⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 beamletsdecoratedpartitiondemo.m

📁 beamlet变化的工具箱
💻 M
字号:
function BeamletsDecoratedPartitionDemo(varargin)
%Usage: BeamletsDecoratedPartitionDemo
%Description: Demo for Beamlets Decorated Partition 
%Version: 6
%Author: Danzhu Shi and Ana Georgina Flesia
%Date: May 8, 2002



if nargin == 0  


	fig = figure(1);



    fs = 8; %default font size

	clf reset;

	set(fig,'pos',[104 229 672 504],'Name', 'Beamlets Decorated Partition Demo', 'NumberTitle', 'off');

    set(fig,'doublebuffer','on','userdata',1);

    txt = strvcat('Please choose the parameters :',...
        'Name : name of a 2-d image.');


    uicontrol( ...
        'tag', 'Instruction_text', ...
        'style', 'text', ...
        'units', 'normal', ...
        'position', [.25 .4 .8 .5], ...
        'string', txt, ...
        'HorizontalAlignment', 'left', ...
        'backgroundcolor', [.8 .8 .8], ...
        'fontsize', fs);

   

    nameRange=['Picasso    '; 'Barton     '; 'Canaletto  '; 'Coifman    '; 'Daubechies '; ...
               'Fingerprint'; 'Lincoln    '; 'Lenna      '; 'MRIScan    '; ...
               'Phone      '];

  


    uicontrol( ...
         'tag','Name_text', ...
         'style','text', ...
         'units','normal', ...
         'position', [.1 .32, .18 .06], ... 
         'string','Name', ...
         'backgroundcolor', [0.8 0.8 0.8],...
         'fontsize',fs);


     


	uicontrol( ...
         'tag','NameRange', ...
         'style','list', ...
         'units','normal', ...
         'position', [.1 .15 .18 .20], ...
         'string',{nameRange}, ...
         'backgroundcolor',[0.8 0.8 0.8], ...
         'fontsize',fs, ...
         'callback', 'BeamletsDecoratedPartitionDemo(''NameRange_Callback'')');


     



     uicontrol( ...
         'tag', 'draw_pushbutton', ...
         'style','pushbutton', ...
         'units','normal', ...
         'position', [.85 .25 .1 .05], ...
         'string','Draw', ...
         'fontsize',fs, ...
         'callback','BeamletsDecoratedPartitionDemo(''draw_Callback'')');




     uicontrol( ...
        'tag', 'close_pushbutton', ...
         'style','pushbutton', ...
         'units','normal', ...
         'position', [.85 .15 .1 .05], ...
         'string','Close', ...
         'fontsize',fs, ...
         'callback','close');





	if nargout > 0


		varargout{1} = fig;


	end





elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK


	try


		if (nargout)


			[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard


        else


			feval(varargin{:}); % FEVAL switchyard


        end


    catch


		disp(lasterr);


    end





end





% --------------------------------------------------------------------


function name = NameRange_Callback



handles = guihandles(gcf);


NameInd = get(handles.NameRange, 'Value');


NameRan = get(handles.NameRange, 'String');


name = NameRan{NameInd};





for k=1:length(name)

    if strcmp(name(k), ' ')==1,

        name = name(1:(k-1));

        break;

    end

end




% --------------------------------------------------------------------


function draw_Callback



name = NameRange_Callback;

MakeBestDecoratedPartition(name);


smartset;


%--------

function MakeBestDecoratedPartition(name)



%------------------------------------------

% to supress the output text by ReadImage.m

global WLVERBOSE        %set by BeamPath.m

WLVERBOSE = 'No';

%------------------------------------------

if strcmp(name, 'Picasso')==1,
im = imread('picasso.256','tiff');
im = double(im);
else
im   = ReadImage(name);
end

[s1,s2]=size(im);
if s1~=s2
    if min(s1,s2)<=256
    im = im(1:min(s1,s2),1:min(s1,s2));
else
    im = im(1:256,1:256);
end
end

n=256;
m=256;

img=im;
img = (img-min(img(:)))./(max(img(:))-min(img(:))); % normalize
img =  sign(2*img - 1).*abs(2*img - 1).^(1/3);
img = -(img-mean(img(:)))./std(img(:));
img_c = (img>.5);

[E,L] = SlowBeamTransAB(img_c); 

lambda = 1;
mEC = E.*(1e-10 + sqrt(L)) - lambda;
[btree,vtree,stree] = BeamletRDP(mEC);

 
subplot(1,2,1)
imagesc(im);axis image;set (gca,'XTick',[]);
set (gca,'YTick',[]); colormap(gray(256));title(name)
c=ones(n, n, 3);
subplot(1,2,2)
image(c); 
axis image; ax = axis; hold on; 
nedges=PlotBeamletRDP2(vtree,btree,stree,'g',ax,log2(n),0,'w',-lambda+1e-3);
title('Recovered by Beamlet-driven RDP'); hold off; 
xlabel(sprintf('Number of beamlets=%d',nedges));set (gca,'XTick',[]);
set (gca,'YTick',[]);

%------------------


WLVERBOSE = 'Yes';


%------------------





%---------------------------------------------


function smartset





chd = get(gcf, 'Children');


set(chd(length(chd)), 'Visible', 'off');


set(chd(1), 'Position', [.6 .25 .25 .8], 'FontSize', 7);


set(chd(2), 'Position', [.2 .25 .25 .8], 'FontSize', 7);




%% Part of BeamLab Version:200% Built:Friday,23-Aug-2002 00:00:00% This is Copyrighted Material% For Copying permissions see COPYING.m% Comments? e-mail beamlab@stat.stanford.edu%%% Part of BeamLab Version:200% Built:Saturday,14-Sep-2002 00:00:00% This is Copyrighted Material% For Copying permissions see COPYING.m% Comments? e-mail beamlab@stat.stanford.edu%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -