@@ -1185,6 +1185,7 @@ function mat2img(mat::Union{GMTgrid,Matrix{<:AbstractFloat}}; x=Float64[], y=Flo
1185
1185
else I. colormap, I. labels, I. n_colors = zeros (Int32,3 ), String[], 0 # Do not inherit this from GI
1186
1186
end
1187
1187
elseif (isa (mat, GMTgrid))
1188
+ (isa (cmap, Symbol) || isa (cmap, String)) && (cmap = grd2cpt (mat, E= 256 , C= cmap))
1188
1189
I = mat2img (img; x= mat. x, y= mat. y, hdr= hdr, proj4= mat. proj4, wkt= mat. wkt, cmap= cmap, is_transposed= is_transp, kw... )
1189
1190
else
1190
1191
I = mat2img (img; x= x, y= y, hdr= hdr, proj4= proj4, wkt= wkt, cmap= cmap, is_transposed= is_transp, kw... )
@@ -1194,7 +1195,7 @@ function mat2img(mat::Union{GMTgrid,Matrix{<:AbstractFloat}}; x=Float64[], y=Flo
1194
1195
end
1195
1196
1196
1197
"""
1197
- imagesc(mat; x=, y=, hdr=, proj4=, wkt=, GI=, clim=, cmap=, kw...)
1198
+ I = imagesc(mat; x=, y=, hdr=, proj4=, wkt=, GI=, clim=, cmap=, kw...)
1198
1199
1199
1200
imagesc takes a Float matrix or a GMTgrid type and scales it (by default) to the [0, 255] interval.
1200
1201
In the process it creates a GMTimage type. Those types can account for coordinates and projection
@@ -1805,20 +1806,24 @@ end
1805
1806
1806
1807
# ---------------------------------------------------------------------------------------------------
1807
1808
"""
1808
- I = ind2rgb(I::GMTimage, cmap ::GMTcpt=GMTcpt(), layout="BRPa")
1809
+ I = ind2rgb(I::GMTimage, cpt ::GMTcpt=GMTcpt(), layout="BRPa"; cmap=GMTcpt() )
1809
1810
1810
1811
Convert an indexed image I to RGB. If `cmap` is not provided, it uses the internal colormap to do the conversion.
1811
1812
If neither them exists, the layer is replicated 3 times thus resulting in a gray scale image.
1813
+
1814
+ Use the `cmap` keyword in alternative to the `cpt` positional variable.
1812
1815
"""
1813
- function ind2rgb (I:: GMTimage , cmap:: GMTcpt = GMTcpt (), layout= " BRPa" )
1814
- (size (I. image, 3 ) >= 3 ) && return I # Image is already RGB(A)
1816
+ function ind2rgb (I:: GMTimage , cpt:: GMTcpt = GMTcpt (), layout= " BRPa" ; cmap= GMTcpt ())
1817
+ (size (I. image, 3 ) >= 3 ) && return I # Image is already RGB(A)
1818
+
1819
+ (isempty (cpt) && isa (cmap, Symbol) || isa (cmap, String)) && (cpt = makecpt (I. range[6 ]- I. range[5 ]+ 1 , C= cmap))
1815
1820
1816
1821
# If the CPT is shorter them maximum in I, reinterpolate the CPT
1817
- (! isempty (cmap ) && (ma = maximum (I. image)) > size (cmap . colormap,1 )) && (cmap = gmt (" makecpt -T0/{$ma }/+n{$ma }" , cmap ))
1818
- _cmap = (! isempty (cmap )) ? cpt2cmap (cmap :: GMTcpt , I. nodata)[1 ] : I. colormap
1822
+ (! isempty (cpt ) && (ma = maximum (I. image)) > size (cpt . colormap,1 )) && (cpt = gmt (" makecpt -T0/{$ma }/+n{$ma }" , cpt ))
1823
+ _cmap = (! isempty (cpt )) ? cpt2cmap (cpt :: GMTcpt , I. nodata)[1 ] : I. colormap
1819
1824
1820
1825
have_alpha = (length (I. colormap) / I. n_colors) == 4 && ! all (I. colormap[end - Int (I. n_colors/ 4 + 1 ): end ] .== 255 )
1821
- if (I. n_colors == 0 && isempty (cmap )) # If no cmap just replicate the first layer.
1826
+ if (I. n_colors == 0 && isempty (cpt )) # If no cmap just replicate the first layer.
1822
1827
imgRGB = repeat (I. image, 1 , 1 , 3 )
1823
1828
layout = I. layout
1824
1829
else
0 commit comments