code: def test_regrid_image():
      # Source data
      fname = (
          config["repo_data_dir"]
          / "raster"
          / "natural_earth"
          / "50-natural-earth-1-downsampled.png"
      )
      nx = 720
      ny = 360
      source_proj = ccrs.PlateCarree()
      source_x, source_y, _ = im_trans.mesh_projection(
          source_proj, nx, ny
      )
      data = plt.imread(fname)
      # Flip vertically to match source_x/source_y orientation
      data = data[::-1]
  
      # Target grid
      target_nx = 300
      target_ny = 300
      target_proj = ccrs.InterruptedGoodeHomolosine(emphasis="land")
      target_x, target_y, target_extent = im_trans.mesh_projection(
          target_proj, target_nx, target_ny
      )
  
      # Perform regrid
      new_array = im_trans.regrid(
          data,
          source_x,
          source_y,
          source_proj,
          target_proj,
          target_x,
          target_y,
      )
  
      # Plot
      fig = plt.figure(figsize=(10, 10))
      gs = mpl.gridspec.GridSpec(
          nrows=4, ncols=1, hspace=1.5, wspace=0.5
      )
      # Set up axes and title
      ax = fig.add_subplot(gs[0], projection=target_proj)
      ax.imshow(new_array, origin="lower", extent=target_extent)
      ax.coastlines()
      # Plot each color slice (tests masking)
      cmaps = {"red": "Reds", "green": "Greens", "blue": "Blues"}
      for i, color in enumerate(["red", "green", "blue"]):
          ax = fig.add_subplot(gs[i + 1], projection=target_proj)
          ax.imshow(
              new_array[:, :, i],
              extent=target_extent,
              origin="lower",
              cmap=cmaps[color],
          )
          ax.coastlines()
  
      # Tighten up layout
      gs.tight_layout(fig)
      return fig
  
file_path: cartopy/lib/cartopy/tests/mpl/test_img_transform.py
imports: from functools import reduce
  import operator
  import matplotlib
  import matplotlib.pyplot
  import numpy
  import pytest
  from cartopy import config
  import cartopy.crs
  from cartopy.tests.conftest import _HAS_PYKDTREE_OR_SCIPY
  import cartopy.img_transform
label_desc: Use image node_id 1 for calling a global function with example usage: test_regrid_image() and returns: fig