From 5dda7968ec569230506595a789a4ee36645f2776 Mon Sep 17 00:00:00 2001 From: Stefan Date: Fri, 24 Feb 2012 23:09:52 +0100 Subject: [PATCH 1/2] ppmwrite writes images properly The previous version just wrote the blue channel to the file. --- examples/image.j | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/image.j b/examples/image.j index 0297e2e35765f..36b912ccfd69c 100644 --- a/examples/image.j +++ b/examples/image.j @@ -40,10 +40,9 @@ function ppmwrite(img, file::String) n, m = size(img) write(s, "$m $n 255\n") for i=1:n, j=1:m - p = img[i, j] - write(s, uint8(redval(p))) - write(s, uint8(greenval(p))) - write(s, uint8(blueval(p))) + write(s, uint8(img[i,j,1])) + write(s, uint8(img[i,j,2])) + write(s, uint8(img[i,j,3])) end close(s) From a27d63652337e53e006d986d334e5d60ab8d604c Mon Sep 17 00:00:00 2001 From: Stefan Date: Fri, 24 Feb 2012 23:13:41 +0100 Subject: [PATCH 2/2] Very basic imshow function The function writes the image on disk using ppmwrite and then shows the image using feh. Therefore depends on having feh installed. I guess it's sufficient for testing purposes. --- examples/image.j | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/image.j b/examples/image.j index 36b912ccfd69c..9247f200c26b2 100644 --- a/examples/image.j +++ b/examples/image.j @@ -93,3 +93,10 @@ function imwrite(I, file::String) close(stream) wait(cmd) end + +function imshow(img) + tmp::String = "./tmp.ppm" + ppmwrite(img, tmp) + cmd = `feh $tmp` + spawn(cmd) +end