@@ -240,21 +240,22 @@ function imview(
240240 # Origin is centre of pixel (1,1) at bottom left.
241241 if ndims (img) == 2
242242 imgT = view (
243- permutedims (img,(2 ,1 )),
243+ permuteddimsview (img,(2 ,1 )),
244244 reverse (axes (img,2 )),
245245 :,
246246 )
247247 elseif ndims (img) >= 3
248248 newdims = (2 ,1 , 3 : ndims (img)... )
249249 ds = Tuple (((:) for _ in 2 : ndims (img)))
250250 imgT = view (
251- permutedims (img,newdims),
251+ permuteddimsview (img,newdims),
252252 reverse (axes (img,2 )),
253253 ds... ,
254254 )
255255 else
256256 imgT = img
257257 end
258+
258259 isempt = isempty (imgT)
259260 if isempt
260261 @warn " imview called with empty argument"
@@ -273,18 +274,7 @@ function imview(
273274 return _imview (imgT, normed, stretch, _lookup_cmap (cmap), contrast, bias)
274275end
275276
276- # Unwrap AstroImages before view, then rebuild.
277- # We have to permute the dimensions of the image to get the origin at the bottom left.
278- # But we don't want this to affect the dimensions of the array.
279- # Also, this reduces the number of methods we need to compile for imview by standardizing types
280- # earlier on. The compiled code for showing an array is the same as an array wrapped by an
281- # AstroImage, except for one unwrapping step.
282- function imview (
283- img:: AstroImage ;
284- kwargs...
285- )
286- return shareheader (img, imview (parent (img); kwargs... ))
287- end
277+
288278
289279# Special handling for complex images
290280"""
@@ -307,8 +297,26 @@ function imview(img::AbstractArray{T}; kwargs...) where {T<:Complex}
307297 vcat (mag_view,angle_view)
308298end
309299
310- function _imview (img, normed:: AbstractArray{T} , stretch, cmap, contrast, bias) where T
300+ # Unwrap AstroImages before view, then rebuild.
301+ # We have to permute the dimensions of the image to get the origin at the bottom left.
302+ # But we don't want this to affect the dimensions of the array.
303+ # Also, this reduces the number of methods we need to compile for imview by standardizing types
304+ # earlier on. The compiled code for showing an array is the same as an array wrapped by an
305+ # AstroImage, except for one unwrapping step.
306+ function _imview (
307+ img:: AstroImage , normed:: AbstractArray{T} , stretch, cmap, contrast, bias
308+ ) where T
311309
310+ p = parent (img)
311+ out = _imview (p, normed, stretch, cmap, contrast, bias)
312+ # out = shareheader(img, v)
313+ return out
314+ end
315+
316+
317+
318+
319+ function _imview (img, normed:: AbstractArray{T} , stretch, cmap, contrast, bias) where T
312320 function colormap (pixr, pixn):: RGBA{N0f8}
313321 if ismissing (pixr) || ! isfinite (pixr) || ismissing (pixn) || ! isfinite (pixn)
314322 # We check pixr in addition to pixn because we want to preserve if the pixels
@@ -341,8 +349,7 @@ function _imview(img, normed::AbstractArray{T}, stretch, cmap, contrast, bias) w
341349 return pix
342350 end
343351 mapper = mappedarray (colormap, img, normed)
344-
345- return maybe_copyheader (img, mapper)
352+ return mapper
346353end
347354
348355
0 commit comments