Mercurial > octave-nkf
comparison scripts/image/saveimage.m @ 5962:2289cafef60d
[project @ 2006-08-24 16:23:12 by jwe]
author | jwe |
---|---|
date | Thu, 24 Aug 2006 16:23:12 +0000 |
parents | 2618a0750ae6 |
children | 34f96dd5441b |
comparison
equal
deleted
inserted
replaced
5961:1c61d6a2c9e6 | 5962:2289cafef60d |
---|---|
123 | 123 |
124 map_sz = map_nr * map_nc; | 124 map_sz = map_nr * map_nc; |
125 | 125 |
126 map = reshape (map, map_sz, 1); | 126 map = reshape (map, map_sz, 1); |
127 | 127 |
128 idx = find (map > 1); | 128 map (map > 1) = 1; |
129 map (idx) = ones (size (idx)); | 129 map (map < 0) = 0; |
130 | |
131 idx = find (map < 0); | |
132 map (idx) = zeros (size (idx)); | |
133 | 130 |
134 map = round (255 * map); | 131 map = round (255 * map); |
135 | 132 |
136 bw = (map_nr == 2 | 133 bw = (map_nr == 2 |
137 && ((map(1,1) == 0 && map(2,1) == 255) | 134 && ((map(1,1) == 0 && map(2,1) == 255) |
141 [img_nr, img_nc] = size (img); | 138 [img_nr, img_nc] = size (img); |
142 | 139 |
143 img_sz = img_nr * img_nc; | 140 img_sz = img_nr * img_nc; |
144 img = reshape (img, img_sz, 1); | 141 img = reshape (img, img_sz, 1); |
145 | 142 |
146 idx = find (img > map_nr); | 143 img (img > map_nr) = map_nr; |
147 img (idx) = ones (size (idx)) * map_nr; | 144 img (img <= 0) = 1; |
148 | |
149 idx = find (img <= 0); | |
150 img (idx) = ones (size (idx)); | |
151 | 145 |
152 if (strcmp (img_form, "ppm")) | 146 if (strcmp (img_form, "ppm")) |
153 | 147 |
154 ## Would be nice to make this consistent with the line used by the | 148 ## Would be nice to make this consistent with the line used by the |
155 ## load/save functions, but we need a good way to get username and | 149 ## load/save functions, but we need a good way to get username and |