# pix2map

(Removed) Convert pixel coordinates to map coordinates

The `pix2map` function has been removed. Use the `intrinsicToWorld` function instead. For more information, see Version History.

## Syntax

```[x,y] = pix2map(R,row,col) s = pix2map(R,row,col) [...] = pix2map(R,p) ```

## Description

`[x,y] = pix2map(R,row,col)` calculates map coordinates `x,y` from pixel coordinates `row,col`. `R` is either a 3-by-2 referencing matrix defining a two-dimensional affine transformation from intrinsic pixel coordinates to map coordinates, or a map raster reference object. `row` and `col` are vectors or arrays of matching size. The outputs `x` and `y` have the same size as `row` and `col`.

`s = pix2map(R,row,col)` combines `x` and `y` into a single array `s`. If `row` and `col` are column vectors of length `n`, then `s` is an `n`-by-2 matrix and each row `(s(k,:))` specifies the map coordinates of a single point. Otherwise, `s` has size `[size(row) 2]`, and `s(k1,k2,...,kn,:)` contains the map coordinates of a single point.

`[...] = pix2map(R,p)` combines `row` and `col` into a single array `p`. If `row` and `col` are column vectors of length `n`, then `p` should be an `n`-by-2 matrix such that each row `(p(k,:))` specifies the pixel coordinates of a single point. Otherwise, `p` should have size ```[size(row) 2]```, and `p(k1,k2,...,kn,:)` should contain the pixel coordinates of a single point.

## Examples

```% Find the map coordinates for the pixel at (100,50). [X,cmap] = imread('concord_ortho_w.tif'); R = worldfileread('concord_ortho_w.tfw','planar',size(X)); [x,y] = pix2map(R,100,50); ```

## Version History

Introduced before R2006a

expand all

### R2024b: Removed

Some functions that accept referencing matrices as input have been removed, including the `pix2map` function. Use a map raster reference object and the `intrinsicToWorld` function instead. Reference objects have several advantages over referencing matrices.

• Unlike referencing matrices, reference objects have properties that document the size of the associated raster, its limits, and the direction of its rows and columns. For more information about reference object properties, see the `MapPostingsReference` and `MapCellsReference` objects.

• You can manipulate the limits of rasters associated with reference objects using the `mapcrop` function.

• You can manipulate the size and resolution of rasters associated with reference objects using the `mapresize` function.

• Most functions that accept referencing matrices as inputs also accept reference objects.

To update your code, first create a reference object for either a raster of cells using the `maprefcells` function or a raster of regularly posted samples using the `maprefpostings` function. Alternatively, convert from a referencing matrix to a reference object using the `refmatToMapRasterReference` function.

Then, replace uses of the `pix2map` function with the `intrinsicToWorld` function according to these patterns.

RemovedRecommended
```[x,y] = pix2map(R,row,col); ```
`[x,y] = intrinsicToWorld(R,col,row);`
```s = pix2map(R,row,col); ```

If `row` and `col` are column vectors:

```[x,y] = intrinsicToWorld(R,col,row); s = [x y];```

If `row` and `col` have size M-by-N or 1-by-N:

```[x,y] = intrinsicToWorld(R,col,row); s = cat(3,x,y);```

`[x,y] = pix2map(R,p);`

If `p` has size N-by-2:

`[x,y] = intrinsicToWorld(R,p(:,2),p(:,1));`