Rice University logo
 
Top blue bar image
 

Archive for the ‘Talks’ Category


Two images generated using latex packages tikz and pgfplots

August 26th, 2012 by wy1

The following images were generated by tikz and pgfplots scripts in latex.

  

The Latex source file is:

\documentclass{article}

\usepackage{tikz, pgfplots}
\usepgfplotslibrary{external}
\tikzexternalize[prefix=figures/]

\begin{document}

\thispagestyle{empty}

\tikzsetnextfilename{L1_ball_fig} % general PDF image L1_ball_fig.pdf
\begin{tikzpicture}[scale=0.5]
   \begin{axis}[hide axis, view={125}{25}, axis equal=true]

        % 3 axes
        \addplot3[thin,dotted,->] coordinates {(-2.4,0,0) (3.0,0,0)};
        \addplot3[thin,dotted,->] coordinates {(0,-2.4,0) (0,3.0,0)};
        \addplot3[thin,dotted,->] coordinates {(0,0,-2.4) (0,0,3.0)};

        % L1 ball boundaries
        \addplot3[thin,domain=0:4/3, samples y=0] (x,0,4/3-x);
        \addplot3[thin,domain=0:4/3, samples y=0] (x,0,x-4/3);

        \addplot3[domain=0:4/3, samples y=0] (0,x,4/3-x);
        \addplot3[domain=0:4/3, samples y=0] (0,x,x-4/3);

        \addplot3[domain=-4/3:0, samples y=0] (x,0,4/3+x);
        \addplot3[dashed, domain=-4/3:0, samples y=0] (x,0,-x-4/3);

        \addplot3[domain=-4/3:0, samples y=0] (0,x,4/3+x);
        \addplot3[dashed, domain=-4/3:0, samples y=0] (0,x,-x-4/3);

        % horizontal lines
        \addplot3[domain=0:4/3, samples y=0] (4/3-x,x,0);
        \addplot3[domain=0:4/3, samples y=0] (x-4/3,x,0);
        \addplot3[dashed, domain=-4/3:0, samples y=0] (-4/3-x,x,0);
        \addplot3[domain=-4/3:0, samples y=0] (4/3+x,x,0);

        % Ax = b
        \addplot3[red,domain=-1.6:3.0, samples y=0] ({(2-x)*1/3},{-(2-x)*1/3},x);

    	% intersection points
    	\addplot3[only marks, mark size=2pt, blue] coordinates{(0,0,2)} node [left] {$\mathbf{x}^o$};
    	\addplot3[only marks, mark size=2pt] coordinates{(2/3,-2/3,0)};
   \end{axis}
\end{tikzpicture}

\tikzsetnextfilename{L05_ball_fig} % general PDF image L05_ball_fig.pdf
\begin{tikzpicture}[scale=0.5]
%   \begin{axis}[xmin=-2, xmax=3, ymin=-2, ymax=3, zmin=-2, zmax=3, hide axis, view={135}{35}, plot box ratio=1 1 2]
   \begin{axis}[hide axis, view={125}{25}, axis equal=true]

        % 3 axes
        \addplot3[thin,dotted,->] coordinates {(-2.2,0,0) (2.8,0,0)};
        \addplot3[thin,dotted,->] coordinates {(0,-2.2,0) (0,2.8,0)};
        \addplot3[thin,dotted,->] coordinates {(0,0,-2.2) (0,0,2.8)};

        % Ax = b
        \addplot3[red,domain=-1.6:3.0, samples y=0] ({(2-x)*1/3},{-(2-x)*1/3},x);

        % L_1/2 ball boundaries
        \addplot3[domain=0:4/2, samples y=0] (x,0,{(sqrt(4/2)-sqrt(x))^2});
        \addplot3[domain=0:4/2, samples y=0] (x,0,-{(sqrt(4/2)-sqrt(x))^2});

        \addplot3[domain=0:4/2, samples y=0] (0,x,{(sqrt(4/2)-sqrt(x))^2});
        \addplot3[domain=0:4/2, samples y=0] (0,x,-{(sqrt(4/2)-sqrt(x))^2});

        \addplot3[domain=-4/2:0, samples y=0] (x,0,{(sqrt(4/2)-sqrt(-x))^2});
        \addplot3[dashed, domain=-4/2:0, samples y=0] (x,0,-{(sqrt(4/2)-sqrt(-x))^2});

        \addplot3[domain=-4/2:0, samples y=0] (0,x,{(sqrt(4/2)-sqrt(-x))^2});
        \addplot3[dashed, domain=-4/2:0, samples y=0] (0,x,-{(sqrt(4/2)-sqrt(-x))^2});

        % connection lines
        \addplot3[domain=0:4/2, samples y=0] ({(sqrt(4/2)-sqrt(x))^2},x,0);
        \addplot3[domain=0:4/2, samples y=0] (-{(sqrt(4/2)-sqrt(x))^2},x,0);
        \addplot3[dashed, domain=-4/2:0, samples y=0] (-{(sqrt(4/2)-sqrt(-x))^2},x,0);
        \addplot3[domain=-4/2:0, samples y=0] ({(sqrt(4/2)-sqrt(-x))^2},x,0);

    	% intersection points
    	\addplot3[only marks, mark size=2pt, blue] coordinates{(0,0,2)} node [left] {$\mathbf{x}^o$};

   \end{axis}
\end{tikzpicture}

\end{document}

To typeset this latex, I used pdflatex with the switch -shell-escape (or -enable-write18 in MikTex). I also used the tools in this blog to crop the white space around the plots.

How to crop a pdf file (and convert it to an eps file)

August 26th, 2012 by wy1

We are going to remove the margin (white space) around a figure in input.pdf. We do this in Linux (I do not find free tools in Windows yet). We need

  1. input.pdf a single-page image file
  2. pdfcrop executable (get from http://sourceforge.net/projects/pdfcrop/)
  3. pdf2eps script (get from http://tex.stackexchange.com/questions/20883/how-to-convert-pdf-to-eps)

I saved a copy of items 2 and 3 here. Of course, you need to put them in the search path and apply “chmod a+x” to them.

Then run the following

  $ pdfcrop --verbose input.pdf output.pdf
  $ pdf2eps 1 output

The second line will generate output.eps.

If we need to impose the same bounding box on more than one files, read the output of

  $ pdfcrop --verbose input1.pdf output1.pdf
  $ pdfcrop --verbose input2.pdf output2.pdf
  ...
  $ pdfcrop --verbose inputn.pdf outputn.pdf

Figure out the largest bounding box <left> <top> <right> <bottom>, and run

  $ pdfcrop --bbox "<left> <top> <right> <bottom>" input1.pdf output1.pdf
  $ pdfcrop --bbox "<left> <top> <right> <bottom>" input2.pdf output2.pdf
  ...
  $ pdfcrop --bbox "<left> <top> <right> <bottom>" inputn.pdf outputn.pdf

Produce eps/pdf files from Matlab figures (almost) exactly as what you see on screen

August 15th, 2012 by wy1

[Download m-file]

function myprint(name, h)
% This code will produce eps and pdf files out of a MATLAB figure with no
% change. What you see will be what you get.
%
% Example:
%
%   h = figure(1);
%   ...(your plotting code) ...
%   myprint('filename', h);
%
% Your will get filename.eps and filename.pdf.
% -----------------
% Wotao Yin (2011).

if ~ischar(name)
    error('Input 1 must be char');
end

if ~exist('h','var') || isempty(h)
    h = gcf;
end

ppos = get(h,'Position'); ppos(1:2)=0; psize = ppos(3:4);
dpi = get(0,'ScreenPixelsPerInch');
set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperUnits', 'inches');
set(gcf, 'PaperSize', psize/dpi);
set(gcf, 'PaperPosition', ppos/dpi);

print('-painters','-depsc2','-r0',name);
print('-painters','-dpdf','-r0',name);

end

Suggests for writing a MATLAB software package

April 2nd, 2011 by wy1

I recently compared TVAL3 and TwIST, and I found several great things about TwIST that make it easier than TVAL3 to apply to my specific application, which has unique sensing operator, data dimension, and TV implements. I merely changed two lines of their main solver algorithm, in addition to writing my own sensing operator and TV-related operations. I am very happy with this experience. We post algorithms online to let people read it, use it, and perhaps improve it. Below, let me summarize a few points that I noticed to have saved my time or would save more.

  1. The main algorithm treats all data as 1D vector, regardless the actual dimension of the user’s data. See below why this is possible. The benefit is that the user won’t need to modify the main algorithm and thus to understand it first.
  2. Implement sensing operators, objective value calculation, shrinkage operations, etc. in separate m-files. Pass them to the main algorithm as function handles. This modularized design allows the user to easily swap in their own implementations.
  3. For point 2, the User’s Manual shall specify the interfaces of various modules. In addition, demos will help.
  4. If an algorithm permits parameter input, a help similar to MATLAB help pages is a good thing to have. The set of parameters can be organized in a table with their defaults, min/max values, and explanations.
  5. (more to come)

Introduction and Overview of Topics II

February 8th, 2011 by wd5

Yangyang Xu: An Alternating Direction Algorithm for Matrix Completion with Nonnegative Factors. (Paper)

Yuan Shen: The Application of PPA Contraction in TVL1 Problem. (Slides)

Cooperative Compressive Sensing for Decentralized Networks

February 8th, 2011 by wd5

 

Speaker:  Zhi Tian, Michigan Technological University

Time:  3-5pm, Friday, 02/18/2011      Location:  DH 1046

Abstract:
Sparsity that characterizes many natural and man-made signals has been exploited over the years in a broad range of statistical inference and signal representation applications, leading to the recent exciting results on compressed sensing for signal reconstruction at sub-Nyquist rates. This talk will discuss the application of compressive sensing for sparse event detection using energy-constrained wireless sensor networks. The physical phenomena under monitoring exhibit localized features that appear sparsely over a large sensing field, which motivate distributed compressive sensing. Meanwhile, for network scalability and robustness, decentralized information processing is considered, in which no fusion center is employed to centrally process all the sensory data. To solve such a sparsity-cognizant cooperative sensing problem in a decentralized manner, we will utilize iterative consensus optimization to search for the globally optimal solutions, under the constraint that sensors transmit at low power and can communicate with their one-hop neighbors only. We will provide several design options, which entail different tradeoffs in communication costs, convergence speed, and sensor awareness level. Further, we will discuss a related cooperative support detection problem, in which sensors seek to consent on the locations of the nonzero elements, but not the amplitudes. A couple of applications will be highlighted, including cooperative spectrum sensing in cognitive radio networks and damage detection in structural health monitoring.

Slides

Biography:
Zhi (Gerry) Tian is an Associate Professor at the department of Electrical and Computer Engineering, Michigan Tech University. Her general interest lies in signal processing for communications. Current research focuses on cognitive radio networks and distributed wireless sensor networking. She served as Associate Editor for IEEE Transactions on Wireless Communications and IEEE Transaction on Signal Processing. She received a CAREER award from the US National Science Foundation in 2003.

Some tricks for numerical simulations in MATLAB

January 25th, 2011 by wy1

Numerical experiments are often used to validate ideas, evaluate algorithms, and compare different approaches on a set of problems. They take time to complete and can be very tiring and even boring sometimes. The post collects tricks that may help make your experience of numerical experiments faster, more productive, and hopefully more fun.

 

  1. Generate unique file names in mass numerical simulations [download m-file]

    % Usage:
    %   filename = gen_filename(base_name, varargin)
    %   where varargin can be ‘hostname’, ‘date’, ‘datetime’,suffix
    %
    % Example:
    %   call
    %     filename = gen_filename(mfilename,’hostname’,’datetime’,’mat’);
    %   in foo.m on PC “yind20” at 23:42:25 on Jan 24, 2011 gives
    %     filename = ‘foo_yind20_20110124T234225.mat’
    %
    % Note: mfilename returns the name of the current m-file.

  2. A template for repeated numerical experiments. [download m-file]
    function simulation_xxx()
    
    %% generate data file's name
    datafile = gen_filename(mfilename,'hostname','datetime','mat');
    [~,host] = system('hostname'); host = host(1:end-1); % get hostname
    
    %% testset's parameters
    par.set1 = 1:2:10;
    par.set2 = 0:0.1:0.5;
    par.nrep = 100;
    
    set1_len = length(par.set1);
    set2_len = length(par.set2);
    
    %% initialize rand gen's seed
    par.seed = 2010; % use fixed seed
    % par.seed = sum(100*clock); % use clock seed
    if isfield(par,'seed')
       fprintf('Seed = %d\n',par.seed);
       RandStream.setDefaultStream(RandStream('mt19937ar','seed',par.seed));
    end
    
    %% generate stationary part of the data
    data.st = generate_st_data( parameters );
    
    %% initialize arrays to save test statistics
    data.resu = cell (set1_len,set2_len,par.nrep);  % store test output, if not too large
    data.psnr = zeros(set1_len,set2_len,par.nrep);  % record PSNRs
    data.mser = zeros(set1_len,set2_len,par.nrep);  % record mean square error
    data.time = zeros(set1_len,set2_len,par.nrep);  % record time
    data.rand = cell (set1_len,set2_len);           % record rand state
    
    %% main iterations
    for ii = 1:set1_len
        par1 = par.set1(ii);
    
        for jj = 1:set2_len
            par2 = par.set2(jj);
    
            data.rand{ii,jj} = get(RandStream.getDefaultStream,'state');
    
            for rep = 1:par.nrep
    
                %% generate complete data
                thisdata = generate_data(data.st, par1, par2);
    
                %% call solver
                tic;
                resu = solver(thisdata,par1,par2);
                data.time(ii,jj,rep) = toc;
    
                %% save and analyze result
                data.resu{ii,jj,rep} = resu; % store test output, if not too large
                [psnr, mser] = analysis(thisdata, resu);
                data.psnr(ii,jj,rep) = psnr;
                data.mser(ii,jj,rep) = mser;
            end
    
            fprintf('%s par1:%4.2f par2:%4.2f avg.psnr:%4.2f avg.mser:%4.2e\n',...
                     host, par1, par2, mean(data.psnr(ii,jj,:)),...
                     mean(data.mser(ii,jj,:)));
            save(datafile,'par','data','ii','jj');
        end
    end
    
    end % function
  3. Obtain the folder of the current m-file in use:
    fileparts(mfilename('fullpath'));

    Example: add subfolder “utilities” to search path

    addpath([fileparts(mfilename('fullpath')) '/utilities']);

Recent updates on Matlab’s random generator

Initializing the Generator with an Integer Seed

 

Initializing the Generator with a State Vector

Edge-Adaptive Image Interpolation with Contour Stencils by Pascal Getreuer

December 26th, 2010 by wy1

Summary:

This talk introduces contour stencils, a new method for estimating the image contours based on total variation along curves.  We apply contour stencils in designing an edge-adaptive image interpolation method, and preliminary results for demosaicing are also shown.

Slides

Slides for MATLA C/MEX programming