> ## Documentation Index
> Fetch the complete documentation index at: https://docs.atomscale.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Compare RHEED Images

> Compare two RHEED images to measure changes in spot count, strain, and mask

Compares two RHEED images and reports how the diffraction pattern changed between them, including the difference in spot count, the referenced strain, and the mask regions gained or lost.

<ParamField query="data_id_1" type="string" required>
  The data entry UUID for the first (initial) RHEED image
</ParamField>

<ParamField query="data_id_2" type="string" required>
  The data entry UUID for the second (final) RHEED image
</ParamField>

## Response

<ResponseField name="data_id_1" type="string">
  Data entry UUID for the first image
</ResponseField>

<ResponseField name="data_id_2" type="string">
  Data entry UUID for the second image
</ResponseField>

<ResponseField name="referenced_strain" type="number">
  Strain of the second image referenced against the first
</ResponseField>

<ResponseField name="spot_count" type="object">
  Change in the number of detected diffraction spots between the two images.

  <Expandable title="properties">
    <ResponseField name="initial" type="number">
      Spot count in the first image
    </ResponseField>

    <ResponseField name="final" type="number">
      Spot count in the second image
    </ResponseField>

    <ResponseField name="percent_change" type="number">
      Percent change in spot count from the first image to the second
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="mask_gained" type="object">
  Mask region present in the second image but not the first, encoded using run-length encoding (RLE). Null if no region was gained.

  <Expandable title="properties">
    <ResponseField name="mask_rle" type="string">
      Run-length encoded mask data
    </ResponseField>

    <ResponseField name="mask_height" type="integer">
      Height of the mask in pixels
    </ResponseField>

    <ResponseField name="mask_width" type="integer">
      Width of the mask in pixels
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="mask_lost" type="object">
  Mask region present in the first image but not the second, encoded using run-length encoding (RLE). Null if no region was lost.

  <Expandable title="properties">
    <ResponseField name="mask_rle" type="string">
      Run-length encoded mask data
    </ResponseField>

    <ResponseField name="mask_height" type="integer">
      Height of the mask in pixels
    </ResponseField>

    <ResponseField name="mask_width" type="integer">
      Width of the mask in pixels
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```python Python theme={null}
  import requests

  response = requests.get(
      "https://api.atomscale.ai/rheed/images/compare/",
      headers={"X-API-KEY": "YOUR_API_KEY"},
      params={
          "data_id_1": "d290f1ee-6c54-4b01-90e6-d701748f0851",
          "data_id_2": "a1b2c3d4-5678-90ab-cdef-1234567890ab"
      }
  )
  comparison = response.json()
  ```

  ```bash cURL theme={null}
  curl "https://api.atomscale.ai/rheed/images/compare/?data_id_1=d290f1ee-6c54-4b01-90e6-d701748f0851&data_id_2=a1b2c3d4-5678-90ab-cdef-1234567890ab" \
    -H "X-API-KEY: YOUR_API_KEY"
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "data_id_1": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "data_id_2": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
    "referenced_strain": 0.42,
    "spot_count": {
      "initial": 12,
      "final": 18,
      "percent_change": 50.0
    },
    "mask_gained": {
      "mask_rle": "0 100 1 50 0 200 ...",
      "mask_height": 512,
      "mask_width": 512
    },
    "mask_lost": null
  }
  ```
</ResponseExample>
