엔지니어가 되고 싶은 공돌이

03. Image File and Format 본문

Computer Science/Image Processing

03. Image File and Format

Geca 2025. 3. 29. 23:33

 

3. 1. Data Type

 

- Data Type:

  int8(8bit integer), uint8(8bit unsigned integer),

  int16, uint16,

  double(Range: Machine Specific).

 

- b = unit8(a); whos a b; (whos: 현재 사용하고 있는 변수의 크기와 타입을 보여주는 함수).

 

 

- 매트랩은 사용전에 변수를 선언하지 않고, 변수의 타입은 입력값에 따라 자동으로 결정됩니다.

 

  정수의 기본형은 double.

 

- 정확한 계산을 위해 double형이 좋고, 영상의 저장은 uint8이 효율적입니다.

 

- Converting Image: gray2rgb(gray -> rgb) : Gray Pixel Value를 R, G, B에 각각 똑같이 복사합니다.

 

  gray2rgb, gray2ind, rgb2gray, rgb2ind(함수 입력에 최대 color 갯수 설정 필요), ind2gray, ind2rgb.

 


 

3. 2. Image File

 

- Image는 Header(Size, Color Map, etc) + Pixel Value로 구성.

 

 

<Vector Image and Raster Image = Bitmap Image>

 

1) Vector Image: 영상의 라인이나 곡선을 수식이나 함수로 표현.

 

- 자연스러운 장면을 연출할 수 는 없지만, 선명한 표현이 가능.

 

  ex) Adobe Illustrator.

 

 

2) Raster Image: 영상을 점을 이용해서 표현.

 

- 자연스러운 장면을 연출할 수 있지만, Aliasing이 발생할 수 있습니다.

 

  ex) Digital Camera, Scanner.

 

 

<Raster Image Format>

 

- 아래 3가지 파일은 압축을 하지 않은 raw 파일로 간단한 Header Information을 가지고 있습니다.

 

1) PBM(Portable BitMap): Binary Image Format.

 

2) PGM(Portable GrayMap): Gray Scale Image Format.

 

3) PPM(Portable PixMap): Color Image Format.

 

- 위의 3가지 포맷을 PNM이라고 하며, 다른 포맷의 변환을 위한 중간 포맷입니다..

 

 

- Microsoft BMP: PGM포맷과 유사, 54Byte Header(42 4D로 시작), Little-Endian 준수.

 


 

3. 3. File Format

 

1) GIF: 네트워크를 통해 영상을 전송하기위해 만듦.

 

- Binary Image, Color Image(Gray Scale X).

 

- LZW Lossless Compression.

 

- 하나의 파일에 여러개의 영상.

 

 

2) PNG: GIF의 단점을 보완한 대체포맷.

 

- Binary GrayScale Color Indexed Image 모두 지원.

 

- LZW Lossless Compression.

 

 

3) JPEG(Header FF D8로 시작): Lossy Compression -> 높은 압축률.

 

- 영상을 8 X 8 Block으로 나누고, 각 블록을 DCT(Discrete Cosine Transform)로 변환.

 

- 원 영상과 복원 영상의 차이를 인간의 눈으로 구분하기 어렵다.

 

 

4) TIFF: 데이터 교환을 위한 우수한 포맷.

 

- 하나의 파일에 여러개의 영상을 저장.

 

- Little-Endian (Header 4D 4D로 시작), Big-Endian(Header 49 49로 시작) 지원.

 

 

5) DICOM: 의학용 디지털 영상의 표준.

 

- 하나의 파일에 여러개의 영상을 저장.

 

- Lossy and Lossless Compression 모두 가능(DCT and Run Length Encoding).

 

 

- imwrite(array, map, 'filename', 'fileformat'); : array를 해당 fileformat으로 저장.


'Computer Science > Image Processing' 카테고리의 다른 글

06. Error Diffusion  (0) 2025.04.08
05. Quantization and Dithering  (0) 2025.04.02
04. Image Display  (0) 2025.04.01
02. Image  (0) 2025.03.20
01. Overview of Image Processing  (0) 2025.03.19
Comments