1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

raspbian の octave が古い

Last updated at Posted at 2019-03-04

GNU octave 公式 を見てみると FLATBUB から入れられるというようなことが書いてある。
とりあえず、入っているのを消す。

> sudo apt list octave
> sudo apt remove octave
> sudo apt autoremove

flatpak を入れて再起動

> sudo apt install flatpak
> sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
> shutdown -r now

起動してきたら octave をインストール。何か足りないものがある雰囲気なので y して実行。

> sudo flatpak install flathub org.octave.Octave
Required runtime for org.octave.Octave/arm/stable (org.kde.Sdk/arm/5.12) is not installed, searching
...
Found in remote flathub, do you want to install it? [y/n]: y
Installing: org.kde.Sdk/arm/5.12 from flathub

> flatpak run org.octave.Octave --gui

5.1.0 きました(^^) --gui がないと cli で起動するみたいです。
そして、先程のグラフを書かせようとすると、すぐに signal 11 で落ちますorz

諦めて flatpak は削除、公式の octave に戻す

> flatpak list
> sudo flatpak uninstall org.octave.Octave
> sudo apt remove flatpak
> sudo apt autoremove
> locate octave
> cd /var/lib/flatpak/..
> sudo rm -rf flatpak/

> sudo apt-cache search octave
> sudo apt install octave

どうも、.eps はモノクロだけど pdf, png, jpg はカラーで出力されます。
それぞれの変換時間を測ってみましたが jpeg と png はほとんど時間が変わらないみたいですね。

Ras1:~/BME280> cat 3D.m 
tx = ty = linspace (-8, 8, 400);
[xx, yy] = meshgrid (tx, ty);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
tz = sin (r) ./ r;
f_handle = figure('visible', 'off');
surfl (tx, ty, tz);
tic();
saveas(f_handle, '3D-image.eps');
elapsed_time_eps = toc()

tic();
saveas(f_handle, '3D-image.pdf');
elapsed_time_pdf = toc()

tic();
saveas(f_handle, '3D-image.jpg');
elapsed_time_jpg = toc()

tic();
saveas(f_handle, '3D-image.gif');
elapsed_time_gif = toc()

tic();
saveas(f_handle, '3D-image.png');
elapsed_time_png = toc()

Ras1:~/BME280> sudo -s /usr/bin/tcsh -c 'time nice -20 octave --no-gui ./3D.m' ;\
time pngquant -f -s1 -o 3D-image_pngquant.png 3D-image.png ;\
ls -ltr --full-time 3D-image*
octave: X11 DISPLAY environment variable not set
octave: disabling GUI features
elapsed_time_eps =  7.1733
elapsed_time_pdf =  61.497
elapsed_time_jpg =  52.752
elapsed_time_gif =  3.6393
elapsed_time_png =  52.852
173.623u 5.770s 2:59.44 99.9%   0+0k 16+174784io 2pf+0w
2.530u 0.050s 0:02.58 100.0%    0+0k 0+264io 0pf+0w
-rw-r--r-- 1 root root 21128755 2019-03-10 20:13:23.182485284 +0900 3D-image.eps
-rw-r--r-- 1 root root  4502269 2019-03-10 20:14:24.672045774 +0900 3D-image.pdf
-rw-r--r-- 1 root root    88235 2019-03-10 20:15:17.491668066 +0900 3D-image.jpg
-rw-r--r-- 1 root root     6722 2019-03-10 20:15:21.131642032 +0900 3D-image.gif
-rw-r--r-- 1 root root   332451 2019-03-10 20:16:13.981263947 +0900 3D-image.png
-rw-r--r-- 1 pi   pi     131768 2019-03-10 20:16:16.821243626 +0900 3D-image_pngquant.png

Ras1:~/BME280> ls -tr 3D-image.* | xargs identify
3D-image.eps PS 576x432 576x432+0+0 16-bit sRGB 83.5KB 0.000u 0:00.000
3D-image.pdf PDF 612x792 612x792+0+0 16-bit sRGB 92.7KB 0.000u 0:00.000
3D-image.jpg JPEG 1200x900 1200x900+0+0 8-bit sRGB 88.2KB 0.000u 0:00.000
3D-image.gif GIF 576x432 576x432+0+0 8-bit sRGB 256c 6.72KB 0.000u 0:00.000
3D-image.png PNG 1200x900 1200x900+0+0 8-bit sRGB 332KB 0.000u 0:00.000
3D-image_pngquant.png PNG 1200x900 1200x900+0+0 8-bit sRGB 256c 132KB 0.000u 0:00.000

eps ファイルが 21M になってしまいました(@_@)
eps, pdf, gif だと何故か解像度が下がりますねぇ?png のファイルサイズはもう少し小さくならないのかな?

pngよ小さくなぁれ
Ras1:~/BME280> optipng -force -clobber -strip all -zc7-9 -zm7-9 -zs0-3 -f0,5 -out 3D-image_o
...
Ras1:~/BME280> pngquant -f -s1 -o 3D-image_optipng_pngquant.png 3D-image_optipng.png
Ras1:~/BME280> ls -l 3D-image*png
-rw-r--r-- 1 root root 332451  3月 10 20:16 3D-image.png
-rw-r--r-- 1 pi   pi   312296  3月 10 20:55 3D-image_optipng.png
-rw-r--r-- 1 pi   pi   131706  3月 10 21:01 3D-image_optipng_pngquant.png
-rw-r--r-- 1 pi   pi   131768  3月 10 20:55 3D-image_pngquant.png
Ras1:~/BME280> identify 3D-image_*.png
3D-image_optipng.png PNG 1200x900 1200x900+0+0 8-bit sRGB 312KB 0.000u 0:00.000
3D-image_optipng_pngquant.png PNG 1200x900 1200x900+0+0 8-bit sRGB 256c 132KB 0.000u 0:00.000
3D-image_pngquant.png PNG 1200x900 1200x900+0+0 8-bit sRGB 256c 132KB 0.000u 0:00.000
Ras1:~/BME280>

png ファイルに pngquant でインデックスカラー (256色パレット) 化すると半分以下になり optipng すると気分だけ小さくなるみたいですね。

試しに Windows の 5.1.0 で実行すると

>> tD

GL2PS info: OpenGL feedback buffer overflow
warning: gl2ps_renderer::draw: retrying with buffer size: 8.4E+06 B
GL2PS info: OpenGL feedback buffer overflow
warning: gl2ps_renderer::draw: retrying with buffer size: 1.7E+07 B
elapsed_time_eps =  8571.0
GL2PS info: OpenGL feedback buffer overflow
warning: gl2ps_renderer::draw: retrying with buffer size: 8.4E+06 B
GL2PS info: OpenGL feedback buffer overflow
warning: gl2ps_renderer::draw: retrying with buffer size: 1.7E+07 B
elapsed_time_pdf =  8634.1
elapsed_time_jpg =  3.5340
elapsed_time_gif =  2.0116
elapsed_time_png =  1.7499

...\octave> dir /OD
...
2019/03/12  00:41               532 tD.m
2019/03/12  03:04        35,150,874 3D-image.eps
2019/03/12  05:28         6,972,278 3D-image.pdf
2019/03/12  05:28            88,302 3D-image.jpg
2019/03/12  05:28         1,528,127 3D-image.gif
2019/03/12  05:28           387,073 3D-image.png
...

なんというか eps と pdf 作成時間が140分ぐらいずつかかってる。それに対して、jpg, gif, png は数秒。
gif のファイルサイズは大きいですねぇ。
画像のピクセル数は gimp で読むと
1200x900 jpeg, gif, png
1170x826 eps
1100x850 pdf
eps と pdf はベクトルデータなので、可変ですけども、デフォルト値ということで。

warning が出てるのは eps と pdf 出力だけみたいなので、jpeg, gif, png は別の出力方法を使ってるんでしょうね。

Rasberry PI の GNU Octave は 4.0.3 なので plotyy のこの辺に引っかかっててうーんとう感じ。Raspberry Pi で Octave を使うには自前でコンパイルしないといけないのかな。
https://savannah.gnu.org/bugs/?46835
https://savannah.gnu.org/bugs/?50497
https://savannah.gnu.org/bugs/?49980

めも
datenum('2019-01-01 0:10:10')
で時刻を time_t ではないけどシリアル値に変換できる。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?