Can grdsample be used to re-sample to increase resolution?

Added by John 2 months ago

Aloha.
I am attempting to take image (jpeg) A (-R0/1572/0/1308) and convert it to B (-R0/3000/0/2672) with -I1/1 (pixel-spacing). I'm looking for advice on 1) whether this is possible and 2) if so, what magic am I missing. I tried increasing the number of nodes but the xmin/xmax/ymin/ymax are the same. I still want -I1/1 but with more rows and columns (nodes?) such that xmin=0, xmax=3000, ymin=0, ymax=2672. Maybe I can't do this with grdsample?

gmt grdsample /Users/hellyj/Projects-200/Project-Zhang/data/level0/AMD-Test-001/Normal.jpeg -G/Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc -R0/1572/0/1308 -I3000+/2672+
+ gmt grdinfo /Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc
/Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc: Title: z
/Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc: Command: grdsample /Users/hellyj/Projects-200/Project-Zhang/data/level0/AMD-Test-001/Normal.jpeg -G/Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc -R0/1572/0/1308 -I3000+/2672+
/Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc: Remark:
/Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc: Pixel node registration used [Cartesian grid]
/Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
/Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc: x_min: 0 x_max: 1572 x_inc: 0.524 name: n_columns: 3000
/Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc: y_min: -2.77555756156e-17 y_max: 1308 y_inc: 0.489520958084 name: n_rows: 2672
/Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc: z_min: -2.63194680214 z_max: 256.016357422 name: z
/Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc: scale_factor: 1 add_offset: 0
/Users/hellyj/Projects-200/Project-Zhang/data/level1/Normal-Resampled.nc: format: netCDF-4 chunk_size: 131,134 shuffle: on deflation_level: 3


Replies (2)

RE: Can grdsample be used to re-sample to increase resolution? - Added by Joaquim 2 months ago

Nope, grdsample is not a good tool for this. You are mixing images and grids. Your jpeg image is a MxNx3 array of uint8. When you pass it to grdsample, it thinks it's a grid and resamples only the first plane (the reds) and saves it as a grid of floats. Though one could force it to write bytes and probably in an image format (plane by plane), I don't think it's a viable way. And again, jpeg images have no axes so if you resample them the increments will always be one (pixel).

RE: Can grdsample be used to re-sample to increase resolution? - Added by John 2 months ago

Mahalo. You saved me a lot of time.
J.

(1-2/2)