Created
June 28, 2010 16:06
-
-
Save duncanmak/456022 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns edu.harvard.connectome.convert-tiff-to-png | |
| (:gen-class) | |
| (:import [ij IJ ImagePlus]) | |
| (:use [clojure.contrib io seq string :as s])) | |
| (defn only-tiff (proxy [java.io.FilenameFilter] [] | |
| (accept [file name] (.endsWith name "tif")))) | |
| (defn replace-extension [file old-ext new-ext] | |
| (.replace (str file) old-ext new-ext)) | |
| (defn convert [in-dir out-dir] | |
| (loop [tiffs (seq (.listFiles in-dir only-tiff))] | |
| (-> (first tiffs) | |
| .getAbsolutePath | |
| IJ/openImage | |
| (IJ/save (str out-dir (replace-extension tiff "tif" "png")))) | |
| (recur (rest tiffs)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment