

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 이미지 세트 픽셀 데이터 가져오기
<a name="get-image-frame"></a>

이미지 프레임은 2D 의료 영상을 구성하기 위해 [이미지 세트](getting-started-concepts.md#concept-image-frame) 내에 존재하는 픽셀 데이터입니다. `GetImageFrame` 작업을 사용하여 HealthImaging에서 지정된 이미지 세트에 대한 HTJ2K-encoded 또는 기본 JPEG 2000 무손실 이미지 프레임을 검색합니다. [이미지 세트](getting-started-concepts.md#concept-image-set) 다음 메뉴에서는 AWS CLI 및 AWS SDKs에 대한 코드 예제를 제공합니다. 자세한 내용은 *AWS HealthImaging API Reference*에서 [https://docs.aws.amazon.com/healthimaging/latest/APIReference/API_GetImageFrame.html](https://docs.aws.amazon.com/healthimaging/latest/APIReference/API_GetImageFrame.html) 섹션을 참조하세요.

**참고**  
`GetImageFrame` 작업을 사용할 때는 다음 사항에 유의하세요.  
[가져오기](importing-imaging-data.md) 중에 HealthImaging은 일부 전송 구문에 대한 인코딩을 유지하고 다른 구문을 HTJ2K 무손실(기본값) 또는 JPEG 2000 무손실로 트랜스코딩합니다. `GetImageFrame` 작업은 인스턴스의 저장된 전송 구문에서 이미지 프레임을 반환합니다. 검색 지연 시간을 최소화하기 위해 검색 중에는 트랜스코딩이 수행되지 않습니다. 전송 구문에 따라 이미지 뷰어에서 보기 전에 이미지 프레임을 디코딩해야 할 수 있습니다. 자세한 내용은 [지원되는 전송 구문](supported-transfer-syntaxes.md) 및 [이미지 프레임 디코딩 라이브러리](reference-libraries.md) 섹션을 참조하세요.
전송 구문의 MPEG 패밀리(MPEG2, MPEG-4 AVC/H.264 및 HEVC/H.265 포함)에 인코딩된 하나 이상의 이미지 프레임이 있는 HealthImaging에 저장된 인스턴스의 경우 `GetImageFrame` 작업은 [저장된 전송 구문](supported-transfer-syntaxes.md)에 비디오 객체를 반환합니다.
이미지 프레임의 전송 구문은 `Content-Type HTTP` 헤더 응답 요소에 지정됩니다. 예를 들어 HTJ2K로 인코딩된 이미지 프레임에는이 있습니다`Content-Type: image/jph header`. 자세한 내용은 *AWS HealthImaging API Reference*에서 [https://docs.aws.amazon.com/healthimaging/latest/APIReference/API_GetImageFrame.html](https://docs.aws.amazon.com/healthimaging/latest/APIReference/API_GetImageFrame.html) 섹션을 참조하세요.
또한 `GetDICOMInstanceFrames` HealthImaging의 DICOMweb 서비스 표현인를 사용하여 DICOMweb 호환 뷰어 및 애플리케이션에 대한 DICOM 인스턴스 프레임(`multipart` 요청)을 검색할 수 있습니다. 자세한 내용은 [HealthImaging에서 DICOM 인스턴스 프레임 가져오기](dicomweb-retrieve-instance-frames.md) 단원을 참조하십시오.

**이미지 세트 픽셀 데이터 가져오기**  
AWS HealthImaging에 대한 액세스 기본 설정에 따라 메뉴를 선택합니다.

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

**참고**  
 AWS Management Console에서는 이미지 뷰어를 사용할 수 없으므로 이미지 프레임은 프로그래밍 방식으로 액세스하고 디코딩해야 합니다.  
이미지 프레임 디코딩 및 보기에 대한 자세한 내용은 [이미지 프레임 디코딩 라이브러리](reference-libraries.md) 섹션을 참조하십시오.

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

------
#### [ C\$1\$1 ]

**SDK for C\$1\$1**  

```
//! 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();
}
```
+  API에 대한 세부 정보는 *AWS SDK for C\$1\$1 API 참조*의 [GetImageFrame](https://docs.aws.amazon.com/goto/SdkForCpp/medical-imaging-2023-07-19/GetImageFrame)을 참조하세요.
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/cpp/example_code/medical-imaging/#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

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

**AWS CLI**  
**이미지 세트 픽셀 데이터 가져오기**  
다음 `get-image-frame` 코드 예시에서는 이미지 프레임을 가져옵니다.  

```
aws medical-imaging get-image-frame \
    --datastore-id "12345678901234567890123456789012" \
    --image-set-id "98765412345612345678907890789012" \
    --image-frame-information imageFrameId=3abf5d5d7ae72f80a0ec81b2c0de3ef4 \
    imageframe.jph
```
참고: GetImageFrame 작업이 픽셀 데이터 스트림을 imageframe.jph 파일에 반환하므로 이 코드 예시에는 출력이 포함되지 않습니다. 이미지 프레임 디코딩 및 보기에 대한 자세한 내용은 HTJ2K 디코딩 라이브러리를 참조하세요.  
자세한 내용은 *AWS HealthImaging 개발자 안내서*의 [이미지 세트 픽셀 데이터 가져오기](https://docs.aws.amazon.com/healthimaging/latest/devguide/get-image-frame.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetImageFrame](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/medical-imaging/get-image-frame.html)을 참조하세요.

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

**SDK for 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);
                }
        }
```
+  API에 대한 세부 정보는 *AWS SDK for Java 2.x API 참조*의 [GetImageFrame](https://docs.aws.amazon.com/goto/SdkForJavaV2/medical-imaging-2023-07-19/GetImageFrame)을 참조하세요.
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/medicalimaging#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

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

**SDK for 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;
};
```
+  API에 대한 세부 정보는 *AWS SDK for JavaScript API 참조*의 [GetImageFrame](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/medical-imaging/command/GetImageFrameCommand)을 참조하세요.
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/medical-imaging#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

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

**SDK for 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
```
다음 코드는 MedicalImagingWrapper 객체를 인스턴스화합니다.  

```
    client = boto3.client("medical-imaging")
    medical_imaging_wrapper = MedicalImagingWrapper(client)
```
+  API 세부 정보는 *AWS SDK for Python (Boto3) API 참조*의 [GetImageFrame](https://docs.aws.amazon.com/goto/boto3/medical-imaging-2023-07-19/GetImageFrame)을 참조하세요.
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/medical-imaging#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

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

**SDK for SAP ABAP API**  

```
    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.
```
+  API 세부 정보는 SDK for SAP ABAP API 참조의 [GetImageFrame](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)을 참조하세요. *AWS * 
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/mig#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

------

**예제 가용성**  
필요한 예제를 찾을 수 없습니까? 이 페이지의 오른쪽 사이드바에 있는 **피드백 제공** 링크를 사용하여 코드 예제를 요청합니다.