

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Mendapatkan data piksel set gambar
<a name="get-image-frame"></a>

[Bingkai gambar](getting-started-concepts.md#concept-image-frame) adalah data piksel yang ada dalam gambar yang diatur untuk membuat gambar medis 2D. [Gunakan `GetImageFrame` tindakan untuk mengambil bingkai gambar lossless JPEG 2000 HTJ2 yang disandikan K atau asli untuk gambar tertentu yang disetel.](getting-started-concepts.md#concept-image-set) HealthImaging Menu berikut memberikan contoh kode untuk AWS CLI dan AWS SDKs. Untuk informasi selengkapnya, lihat [https://docs.aws.amazon.com/healthimaging/latest/APIReference/API_GetImageFrame.html](https://docs.aws.amazon.com/healthimaging/latest/APIReference/API_GetImageFrame.html)di *AWS HealthImaging API Referensi*.

**catatan**  
Ingatlah poin-poin berikut saat menggunakan `GetImageFrame` tindakan:  
Selama [impor](importing-imaging-data.md), HealthImaging mempertahankan pengkodean untuk beberapa sintaks transfer, dan mentranskode yang lain ke HTJ2 K lossless (default) atau JPEG 2000 Lossless. `GetImageFrame`Tindakan mengembalikan bingkai gambar dalam sintaks transfer tersimpan dari instance. Tidak ada transcoding yang dilakukan selama pengambilan untuk memastikan latensi pengambilan minimal. Bingkai gambar mungkin perlu diterjemahkan sebelum dilihat di penampil gambar, tergantung pada sintaks transfer. Untuk informasi selengkapnya, lihat [Sintaks transfer yang didukung](supported-transfer-syntaxes.md) dan [Pustaka decoding bingkai gambar](reference-libraries.md).
[Untuk contoh yang disimpan HealthImaging dengan satu atau lebih bingkai gambar yang dikodekan dalam keluarga MPEG Transfer Syntax (yang mencakup MPEG2, MPEG-4 AVC/H.264 and HEVC/H .265) `GetImageFrame` tindakan akan mengembalikan objek video dalam sintaks transfer yang disimpan.](supported-transfer-syntaxes.md)
Sintaks transfer frame gambar ditentukan dalam elemen respon `Content-Type HTTP` header. Misalnya, bingkai gambar yang dikodekan dalam HTJ2 K akan memiliki. `Content-Type: image/jph header` Untuk informasi selengkapnya, lihat [https://docs.aws.amazon.com/healthimaging/latest/APIReference/API_GetImageFrame.html](https://docs.aws.amazon.com/healthimaging/latest/APIReference/API_GetImageFrame.html)di *AWS HealthImaging API Referensi*.
Anda juga dapat menggunakan representasi DICOMweb layanan`GetDICOMInstanceFrames`, HealthImaging untuk mengambil frame (`multipart`permintaan) instans DICOM untuk pemirsa dan aplikasi DICOMweb yang kompatibel. Untuk informasi selengkapnya, lihat [Mendapatkan bingkai instans DICOM dari HealthImaging](dicomweb-retrieve-instance-frames.md).

**Untuk mendapatkan data piksel set gambar**  
Pilih menu berdasarkan preferensi akses Anda ke AWS HealthImaging.

## AWS Konsol
<a name="code-example-console-image-set-get-pixel-data"></a>

**catatan**  
Bingkai gambar harus diakses dan diterjemahkan secara terprogram, karena penampil gambar tidak tersedia di file. Konsol Manajemen AWS  
Untuk informasi selengkapnya tentang decoding dan melihat bingkai gambar, lihat. [Pustaka decoding bingkai gambar](reference-libraries.md)

## AWS CLI dan SDKs
<a name="code-example-cli-sdk-image-set-get-pixel-data"></a>

------
#### [ C\+\+ ]

**SDK untuk C\+\+**  

```
//! Routine which downloads an AWS HealthImaging image frame.
/*!
  \param dataStoreID: The HealthImaging data store ID.
  \param imageSetID: The image set ID.
  \param frameID: The image frame ID.
  \param jphFile: File to store the downloaded frame.
  \param clientConfig: Aws client configuration.
  \return bool: Function succeeded.
*/
bool AwsDoc::Medical_Imaging::getImageFrame(const Aws::String &dataStoreID,
                                            const Aws::String &imageSetID,
                                            const Aws::String &frameID,
                                            const Aws::String &jphFile,
                                            const Aws::Client::ClientConfiguration &clientConfig) {
    Aws::MedicalImaging::MedicalImagingClient client(clientConfig);

    Aws::MedicalImaging::Model::GetImageFrameRequest request;
    request.SetDatastoreId(dataStoreID);
    request.SetImageSetId(imageSetID);

    Aws::MedicalImaging::Model::ImageFrameInformation imageFrameInformation;
    imageFrameInformation.SetImageFrameId(frameID);
    request.SetImageFrameInformation(imageFrameInformation);

    Aws::MedicalImaging::Model::GetImageFrameOutcome outcome = client.GetImageFrame(
            request);

    if (outcome.IsSuccess()) {
        std::cout << "Successfully retrieved image frame." << std::endl;
        auto &buffer = outcome.GetResult().GetImageFrameBlob();

        std::ofstream outfile(jphFile, std::ios::binary);
        outfile << buffer.rdbuf();
    }
    else {
        std::cout << "Error retrieving image frame." << outcome.GetError().GetMessage()
                  << std::endl;

    }

    return outcome.IsSuccess();
}
```
+  Untuk detail API, lihat [GetImageFrame](https://docs.aws.amazon.com/goto/SdkForCpp/medical-imaging-2023-07-19/GetImageFrame)di *Referensi AWS SDK untuk C\+\+ API*. 
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/cpp/example_code/medical-imaging/#code-examples). 

------
#### [ CLI ]

**AWS CLI**  
**Untuk mendapatkan data piksel set gambar**  
Contoh `get-image-frame` kode berikut mendapat bingkai gambar.  

```
aws medical-imaging get-image-frame \
    --datastore-id {{"12345678901234567890123456789012"}} \
    --image-set-id {{"98765412345612345678907890789012"}} \
    --image-frame-information {{imageFrameId=3abf5d5d7ae72f80a0ec81b2c0de3ef4}} \
    {{imageframe.jph}}
```
Catatan: Contoh kode ini tidak menyertakan output karena GetImageFrame tindakan mengembalikan aliran data piksel ke file imageframe.jph. Untuk informasi tentang decoding dan melihat bingkai gambar, lihat HTJ2 K decoding library.  
Untuk informasi selengkapnya, lihat [Mendapatkan data piksel yang disetel gambar](https://docs.aws.amazon.com/healthimaging/latest/devguide/get-image-frame.html) di *Panduan AWS HealthImaging Pengembang*.  
+  Untuk detail API, lihat [GetImageFrame](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/medical-imaging/get-image-frame.html)di *Referensi AWS CLI Perintah*. 

------
#### [ Java ]

**SDK untuk Java 2.x**  

```
        public static void getMedicalImageSetFrame(MedicalImagingClient medicalImagingClient,
                        String destinationPath,
                        String datastoreId,
                        String imagesetId,
                        String imageFrameId) {

                try {
                        GetImageFrameRequest getImageSetMetadataRequest = GetImageFrameRequest.builder()
                                        .datastoreId(datastoreId)
                                        .imageSetId(imagesetId)
                                        .imageFrameInformation(ImageFrameInformation.builder()
                                                        .imageFrameId(imageFrameId)
                                                        .build())
                                        .build();
                        medicalImagingClient.getImageFrame(getImageSetMetadataRequest,
                                        FileSystems.getDefault().getPath(destinationPath));

                        System.out.println("Image frame downloaded to " + destinationPath);
                } catch (MedicalImagingException e) {
                        System.err.println(e.awsErrorDetails().errorMessage());
                        System.exit(1);
                }
        }
```
+  Untuk detail API, lihat [GetImageFrame](https://docs.aws.amazon.com/goto/SdkForJavaV2/medical-imaging-2023-07-19/GetImageFrame)di *Referensi AWS SDK for Java 2.x API*. 
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/medicalimaging#code-examples). 

------
#### [ JavaScript ]

**SDK untuk JavaScript (v3)**  

```
import { GetImageFrameCommand } from "@aws-sdk/client-medical-imaging";
import { medicalImagingClient } from "../libs/medicalImagingClient.js";

/**
 * @param {string} imageFrameFileName - The name of the file for the HTJ2K-encoded image frame.
 * @param {string} datastoreID - The data store's ID.
 * @param {string} imageSetID - The image set's ID.
 * @param {string} imageFrameID - The image frame's ID.
 */
export const getImageFrame = async (
  imageFrameFileName = "image.jph",
  datastoreID = "DATASTORE_ID",
  imageSetID = "IMAGE_SET_ID",
  imageFrameID = "IMAGE_FRAME_ID",
) => {
  const response = await medicalImagingClient.send(
    new GetImageFrameCommand({
      datastoreId: datastoreID,
      imageSetId: imageSetID,
      imageFrameInformation: { imageFrameId: imageFrameID },
    }),
  );
  const buffer = await response.imageFrameBlob.transformToByteArray();
  writeFileSync(imageFrameFileName, buffer);

  console.log(response);
  // {
  //     '$metadata': {
  //         httpStatusCode: 200,
  //         requestId: 'e4ab42a5-25a3-4377-873f-374ecf4380e1',
  //         extendedRequestId: undefined,
  //         cfId: undefined,
  //         attempts: 1,
  //         totalRetryDelay: 0
  //     },
  //     contentType: 'application/octet-stream',
  //     imageFrameBlob: <ref *1> IncomingMessage {}
  // }
  return response;
};
```
+  Untuk detail API, lihat [GetImageFrame](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/medical-imaging/command/GetImageFrameCommand)di *Referensi AWS SDK untuk JavaScript API*. 
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/medical-imaging#code-examples). 

------
#### [ Python ]

**SDK untuk Python (Boto3)**  

```
class MedicalImagingWrapper:
    def __init__(self, health_imaging_client):
        self.health_imaging_client = health_imaging_client


    def get_pixel_data(
        self, file_path_to_write, datastore_id, image_set_id, image_frame_id
    ):
        """
        Get an image frame's pixel data.

        :param file_path_to_write: The path to write the image frame's HTJ2K encoded pixel data.
        :param datastore_id: The ID of the data store.
        :param image_set_id: The ID of the image set.
        :param image_frame_id: The ID of the image frame.
        """
        try:
            image_frame = self.health_imaging_client.get_image_frame(
                datastoreId=datastore_id,
                imageSetId=image_set_id,
                imageFrameInformation={"imageFrameId": image_frame_id},
            )
            with open(file_path_to_write, "wb") as f:
                for chunk in image_frame["imageFrameBlob"].iter_chunks():
                    if chunk:
                        f.write(chunk)
        except ClientError as err:
            logger.error(
                "Couldn't get image frame. Here's why: %s: %s",
                err.response["Error"]["Code"],
                err.response["Error"]["Message"],
            )
            raise
```
Kode berikut membuat instance objek. MedicalImagingWrapper   

```
    client = boto3.client("medical-imaging")
    medical_imaging_wrapper = MedicalImagingWrapper(client)
```
+  Untuk detail API, lihat [GetImageFrame](https://docs.aws.amazon.com/goto/boto3/medical-imaging-2023-07-19/GetImageFrame)di *AWS SDK for Python (Boto3) Referensi* API. 
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/medical-imaging#code-examples). 

------
#### [ SAP ABAP ]

**SDK for SAP ABAP**  

```
    TRY.
        " iv_datastore_id = '1234567890123456789012345678901234567890'
        " iv_image_set_id = '1234567890123456789012345678901234567890'
        " iv_image_frame_id = '1234567890123456789012345678901234567890'
        oo_result = lo_mig->getimageframe(
          iv_datastoreid = iv_datastore_id
          iv_imagesetid = iv_image_set_id
          io_imageframeinformation = NEW /aws1/cl_migimageframeinfmtion(
            iv_imageframeid = iv_image_frame_id ) ).
        DATA(lv_frame_blob) = oo_result->get_imageframeblob( ).
        MESSAGE 'Image frame retrieved.' TYPE 'I'.
      CATCH /aws1/cx_migaccessdeniedex.
        MESSAGE 'Access denied.' TYPE 'I'.
      CATCH /aws1/cx_migconflictexception.
        MESSAGE 'Conflict error.' TYPE 'I'.
      CATCH /aws1/cx_miginternalserverex.
        MESSAGE 'Internal server error.' TYPE 'I'.
      CATCH /aws1/cx_migresourcenotfoundex.
        MESSAGE 'Image frame not found.' TYPE 'I'.
      CATCH /aws1/cx_migthrottlingex.
        MESSAGE 'Request throttled.' TYPE 'I'.
      CATCH /aws1/cx_migvalidationex.
        MESSAGE 'Validation error.' TYPE 'I'.
    ENDTRY.
```
+  Untuk detail API, lihat [GetImageFrame](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)di *AWS SDK untuk referensi SAP ABAP* API. 
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/mig#code-examples). 

------

**Ketersediaan contoh**  
Tidak dapat menemukan apa yang Anda butuhkan? Minta contoh kode menggunakan tautan **Berikan umpan balik** di bilah sisi kanan halaman ini.