Compressing papers with ghostscript

May 5, 2017 Research

When searching for ways to compress the size of a ~50MB paper pdf, I’ve discovered the following ghostscript command (askUbuntu, TeX StackExchange)

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed.pdf original.pdf

Argument of -dPDFSETTINGS can be any of:

-dPDFSETTINGS=/screen   # lower quality, smaller size.
-dPDFSETTINGS=/ebook    # for better quality, but slightly larger pdfs.
-dPDFSETTINGS=/prepress # output similar to Acrobat Distiller "Prepress Optimized" setting
-dPDFSETTINGS=/printer  # selects output similar to the Acrobat Distiller "Print Optimized" setting

(descriptions copy-pasted from askUbuntu)

I wrote a small script to test the different -dPDFSETTINGS modes.

Read More

3d fabricated lilium

Feb 15, 2017 Research

We got this giant plastic lilium for the tests of our sensor surface reconstruction. Looking forward to the experiments!

(The small device in the middle is the Morphorider.)

Array multiplicities via sparse

Feb 6, 2017 Matlab

Multiplicities of array elements can be efficiently computed using sparse. I’ve found this elegant solution in an old Newsgroup thread.

% generate some data
A = randi(10,1,100);
% construct the sparse matrix
S = sparse(A,1,1);
% get unique elements and multiplicities
[uA,~,mult] = find(S);
mult =
   (1,1)        8
   (2,1)       15
   (3,1)       11
   (4,1)        5
   (5,1)       10
   (6,1)        6
   (7,1)       10
   (8,1)       13
   (9,1)       13
  (10,1)        9

This method is faster than other solutions – almost twice as fast as histc.

% test array: 2000 random integers from the set 1:1000
% 1000 iterations
Elapsed time is 0.228704 seconds. % histc
Elapsed time is 1.838388 seconds. % bsxfun
Elapsed time is 0.128791 seconds. % sparse