2017년 4월 23일 일요일

Image Process Pipeline

Image Sensor 에서 이미지를 획득(Acquisition) 한 다음 이미지 프로세싱을 수행하고 이 이미지 프로세싱을 나열한 것이 pipeline 이다. 이 pipeline 이 지나면 최종 이미지(YUV 이미지?)가 생성된다.

So what purpose does ISP have? Well, pixels are sensitive to light between some set of wavelengths, essentially they’re color agnostic.
ISP 의 목적은 무엇인가? pixel은 빛에 민감하다(관련된 특성은 빛 파장이며, 이 때 색은 감지하지 못한다(agnostic, 불가지론의).)

The way to get a color image out is to put a filter on top, usually a bayer pattern color filter, then interpolate the color of the pixels adjacent.
색을 얻는 방법은 필터를 센서 위에 두는 것이다, 보통 베이어 패턴의 색 필터를 사용한다. 그 후에는 interpolate로 주변 픽셀의 색을 구한다. (한 픽셀은 R, G, B 중 한가지만 얻을 수 있기 때문에)

Your 8 MP CMOS doesn’t sense red green and blue for each pixel, it senses one color for each, then ISP guesses the color based on what’s next to it. This is called demosaicing, and it’s probably the primary job of ISP, and there are many secret sauce methods to computing this interpolated image.
8메가의 CMOS 센서는 빨간색, 녹색, 파란색을 각 픽셀에서 얻지 못한다. 하나가지 색만 감지해 낼 수 있다. 그리고 ISP는 주변의 색을 추측 해 낸다. 이것을 demosic 한다고 한다. 이것이 ISP의 가장 기본적인 일이다. 그리고 ISP는 이 interpolate 된 이미지를 가지고 많은 일을 한다.

In addition ISP does all the other housekeeping, it controls autofocus, exposure, and white balance for the camera system.
ISP는 autofocus, exposure, white balance 도 한다.

Recently correcting for lens imperfections like vignetting or color shading imparted by the imperfect lens system (which you’ll add right back in with instagram, you heathen) has been added, along with things like HDR recombining, noise reduction, other filtering, face or object detection, and conversion between color spaces.
최근에는 lens의 불완전함(비네팅, 컬러 쉐이딩 - 렌즈의 불완전함 때문에 생긴) 을 바로 잡기도 하며 HDR recombining, noise reduction, 다른 filtering, 얼굴 인식, 물체 인식, 색 공간간의변환 등도 수행 합니다.

There’s variance between the features that ISP does, but this is really the controller for getting that bayer data into a workable image array.
ISP 에서 하는 일은 ISP의 종류에 따라 다양 하지만, bayer를 사용 가능한 image array 로 만든 다음 그것을 조작 하는 것임은 틀림 없습니다.



참조
http://www.anandtech.com/show/6777/understanding-camera-optics-smartphone-camera-trends/4
https://www.einfochips.com/blog/consumer-electronics/a-peek-inside-your-camera-i-image-signal-processing-isp-pipeline.html
https://www.einfochips.com/blog/consumer-electronics/a-peek-inside-your-camera-ii-image-sensor-modules.html

Image Sensor

Image Processing 을 이해하기 위한 Image Sensor 종류 확인

보통 CMOS 센서를 쓰고, 빛의 양(회색 빛)을 숫자로 받을 수 있으며 색을 확인하기 위하여 Bayer filter 를 사용하여 interpolation 을 하면 digitize(숫자화, 여기서는 양자화 까지 포함?) 된, matrix 형태의 이미지를 받을 수있다.
궁금한 것은 sensor 의 셋팅을 통하여 센서에서 받는 이미지의 값이 달라지고 이것이 최종 이미지 품질을 변화시킬 텐데
sensor 셋팅을 통해서 할 수있는 일들이 무엇인지 궁금하다. 왜냐하면 이미지 프로세싱과 구분이 잘 안되기 때문이다.


아래 내용 참조: https://en.wikipedia.org/wiki/Image_sensor

An image sensor or imaging sensor is a sensor that detects and conveys the information that constitutes an image. It does so by converting the variable attenuation of light waves (as they pass through or reflect off objects) into signals, small bursts of current that convey the information. The waves can be light or other electromagnetic radiation. Image sensors are used in electronic imaging devices of both analog and digital types, which include digital cameras, camera modules, medical imaging equipment, night vision equipment such as thermal imaging devices, radar, sonar, and others. As technology changes, digital imaging tends to replace analog imaging.
이미지 센서 혹은 이미징 센서는 이미지 정보를 감지하고 전달한다. 빛 파장의 가변감쇄를 통하여(통과 시키거나 반사하면서) 시그널이나, 적은 저항으로 이미지 정보를 저장한다. 그 파자은 빛이나 다른 전자기복사가 될 수 있다. 이미지 센서는 전자 이미지 장치(아날로그, 디지털 타입 모두)에 사용된다. 디지털 카메라, 카메라 모듈, 의료 이미징 장비, 야간 투시경 장비(열 감지 장치, 레이다, 음향포정장치 등)에 사용된다. 기술이 변화하면서 디지털 이미징은 아날로그 이미징으로 옮겨가고 있다.

Early analog sensors for visible light were video camera tubes. Currently, used types are semiconductor charge-coupled devices (CCD) or active pixel sensors in complementary metal–oxide–semiconductor (CMOS) or N-type metal-oxide-semiconductor (NMOS, Live MOS) technologies. Analog sensors for invisible radiation tend to involve vacuum tubes of various kinds. Digital sensors include flat panel detectors.
초기 사람에게 보이는 영역(가시광)을 위한 아날로그 센서는 비디오 카메라 튜브 였습니다. 현재 사용되는 센서의 타입은 반도체 CCD(charge-coupled devices)나 active Pixel sensor인 CMOS(complementary metal–oxide–semiconductor) 혹은 NMOS(N-type metal-oxide-semiconductor) 기술 입니다. 보이지 않는 영역을 위한 아날로그 센서는 다양한 vaccum tube를 포함하고 있습니다. 디지털 센서는 평평한 판넬 감지기를 포함합니다.


CCD vs CMOS technology
Today, most digital cameras use a CMOS sensor, because CMOS sensors perform better than CCDs. An example is the fact that they incorporate an integrated circuit, helping reduce costs. CCD is still in use for cheap low entry cameras, but weak in burst mode.[1] Both types of sensor accomplish the same task of capturing light and converting it into electrical signals.
오늘, 대부분의 디지털 카메라는 CMOS 센서를 사용한다. 왜냐하면 CMOS 센서는 CCD 보다 나은 성능을 내기 때문이다(-.-;). 예를 들면 CMOS는 가격을 줄이는 데 도움이 되는 집적회로를 포함하고 있다. CCD는 보통 싼 기본기능이 탑재된 카메라에 쓰인다. 하지만 독점 방식에 약하다. 두개의 (센서)타입 모두 빛을 캡쳐해서 전자 시그널로 변환하는 기능을 수행한다.

Each cell of a CCD image sensor is an analog device. When light strikes the chip it is held as a small electrical charge in each photo sensor. The charges in the line of pixels nearest to the (one or more) output amplifiers are amplified and output, then each line of pixels shifts its charges one line closer to the amplifier(s), filling the empty line closest to the amplifiers(s). This process is then repeated until all the lines of pixels have had their charge amplified and output.[2]
CCD 이미지 센서의 각 셀은 아날로그 장치이다. 빛이 센서의 개별 칩(픽셀)에 부딧힐 때 작은 전하가 생긴다. 아웃풋 증폭기와 가까운 row 픽셀 라인의 전하들은 증폭되고 아웃풋 된다(?) 그리고 각 픽셀 라인은 그 전하를 가장 가까운 빈 라인을 채우면서 한 라인 가까운 증폭기에 시프트 시킨다. 이프로세스는 모든 픽셀 라인이 전하로 채워질 때까지 계속된다.

A CMOS image sensor has an amplifier for each pixel compared to the few amplifiers of a CCD. This results in less area for the capture of photons than a CCD, but this problem has been overcome by using microlenses in front of each photodiode, which focus light into the photodiode that would have otherwise hit the amplifier and not be detected.[3] Some CMOS imaging sensors also use Back-side illumination to increase the number of photons that hit the photodiode.
CMOS 이미지 센서는 각 픽셀에 증폭기가 달려있어 상대적으로 적은 CCD 와 비교된다. 이 차이가 적은 포톤을 잡는 특징을 만들었지만, 이 문제는 각 포토다이오드 앞에 빛을 포토다이오드에 포커스 하게 해주는 마이크로렌즈를 사용함으로써 빛이 증폭기를 비춰서 디텍트 되지 않을수 있는 위험을 없애 주었다. 일부 CMOS 이미지 센서는 뒷면 조명을 사용하여 포토 다이오드를 치는 포톤의 수를 증가시켜 주었다.(?)

CMOS sensors can potentially be implemented with fewer components, use less power, and/or provide faster readout than CCD sensors.[4] They are also less vulnerable to static electricity discharges.
CMOS 센서는 CCD보다 잠재적으로 적은 수, 적은 파워 그리고 빠른 해독이 가능하다. 그리고 정전기에도 덜 연약하다.

Another hybrid CCD/CMOS architecture, sold under the name "sCMOS," consists of CMOS readout integrated circuits (ROICs) that are bump bonded to a CCD imaging substrate – a technology that was developed for infrared staring arrays and now adapted to silicon-based detector technology.[5] Another approach is to utilize the very fine dimensions available in modern CMOS technology to implement a CCD like structure entirely in CMOS technology. This can be achieved by separating individual poly-silicon gates by a very small gap. These hybrid sensors are still in the research phase and can potentially harness the benefits of both CCD and CMOS imagers.[6]
또 다른 CCD/CMOS 를 조합한 구조는, 'sCMOS' 라고 하며, CMOS 해독 집적회로(ROICs) 가 CCD 이미지 기판에 붙어 있다 - 이 기술은 적외선 응시 배열 때문에 만들어 졌으며 지금은 실리콘 기반의 탐지 기술에도 적용 되고 있다.  ...

Performance
There are many parameters that can be used to evaluate the performance of an image sensor, including dynamic range, signal-to-noise ratio, and low-light sensitivity. For sensors of comparable types, the signal-to-noise ratio and dynamic range improve as the size increases.


Color separation
There are several main types of color image sensors, differing by the type of color-separation mechanism:
color 를 sensing 하기 위하면 몇가지 다른 방법이 있다.

1) Bayer filter sensor,
low-cost and most common, using a color filter array that passes red, green, or blue light to selected pixel sensors, forming interlaced grids sensitive to red, green, and blue – the missing color samples are interpolated using a demosaicing algorithm. In order to avoid interpolated color information, techniques like color co-site sampling use a piezo mechanism to shift the color sensor in pixel steps. The Bayer filter sensors also include back-illuminated sensors, where the light enters the sensitive silicon from the opposite side of where the transistors and metal wires are, such that the metal connections on the devices side are not an obstacle for the light, and the efficiency is higher.[7][8]

2) Foveon X3 sensor,
using an array of layered pixel sensors, separating light via the inherent wavelength-dependent absorption property of silicon, such that every location senses all three color channels.

3) 3CCD,
using three discrete image sensors, with the color separation done by a dichroic prism.






















2017년 4월 22일 토요일

Video compression picture types(I, P, B frames)

계기: i frame 과  p frame 이 무엇이고 그 차이점을 이해하기 하기 위하여

I‑frame (Intra-coded picture)
사진의 모든 정보, P-frame과 B-frame은 이미지의 일부(압축된)만 가지고 있으므로 I-frame에 비해 크기가 작다.

P-frame (Predicted picture)
이전 이미지에서 변경된 정보만을 가지고 있는 frame. delta-frames 라고도 부른다.

B-frame(Bi-predictive picture)
지금, 이전, 그리고 다음의 프레임의 다른 점을 저장하여 더(P-frame 보다?) 공간을 줄이는 것

참조: https://en.wikipedia.org/wiki/Video_compression_picture_types

VGA와 HD의 차이점

VGA: Video Graphics Array
HD: High Definition

풀HD는 :1080i/p  (1920*1080)의 픽셜갯수를 갖은 영상!!
HD는 :  720i/p    (1280* 720)의 픽셜의 갯수를 갖은 영상!!
VGA는:              (640*480  ) 의 픽셜의 갯수를 갖은 영상이라고 생각하면 됩니다


Video Connector 종류






참조: http://www.bobaedream.co.kr/board/bulletin/view.php?code=tour&No=410315

HDR 과 SDR

HDR: High Dynamic Range
SDR: Standard Dynamic Range

Dynamic Range:  ratio between the largest and smallest values that a certain quantity can assume.

SDR:  the dynamic range of images/rendering/video using a conventional gamma curve.

참조: http://communityforums.rogers.com/t5/blogs/blogarticlepage/blog-id/CommunityBlog/article-id/806



conventional: 전통적인

gamma correction: 목적은 인간 시각의 비선형성에 맞추어 정보를 부호화하려는 것이므로, 많은 경우 감마 부호화(gamma encoding)라는 표현이 더 적합하다. 인간 시각은 카메라의 다이나믹 레인지보다 훨씬 높은 명암차이를 감지할 수 있으며 색상이나 해상도차이에 비해 명암의 차이에 민감하다. 디스플레이 장치의 발전에 따라서 다이나믹 레인지를 보다 잘 표현하기 위해서 기존의 영상 시스템의 활용성을 높이면서 시각에 민감한 부분의 데이터를 보다 효율적으로 압축 전달하기 위한 방향으로 gamma encoding이 개발, 발전 되고 있다.
참조
    1) https://en.wikipedia.org/wiki/Gamma_correction
    2) https://ko.wikipedia.org/wiki/%EA%B0%90%EB%A7%88_%EB%B3%B4%EC%A0%95


2017년 4월 17일 월요일

Simplicity(C 언어) 사용 시 Terminology

대상: Chip C8051-F560


CLI: Command Line Interface

HCI: Human–computer interaction

SMbus: The System Management Bus (abbreviated to SMBus or SMB) is a single-ended simple two-wire bus for the purpose of lightweight communication.

숫자 뒤의 'U'
C 언어에서 기본으로 int 이므로 뒤에 U 를 쓰면 unsigned 가 된다.
참조: http://stackoverflow.com/questions/9029974/what-does-u-mean-after-a-number

Interrupt
TCON: Timer Control
Edge/Level triggered interrupt 두 방법의 차이
Edge Trigger 는 rising 혹은 falling edge 가 발생할 때 interrupt 가 발생되는 것
Level Trigger 는 특정 Level이 될 때 interrupt 가 발생되는 것

참조: https://electronics.stackexchange.com/questions/21886/what-does-edge-triggered-and-level-triggered-mean

IT01CF: INT0/INT1 Configuration
IT01CF = 0x0E -> (00001110)
IN0PL: 1 => INT0 Polarity, 1: INT0 input is active high
IN0SL:  INT0 Port Pin Selection Bits
IN0SL[2:0]:110 =>  110: Select P1.6

Timer
When the 8-bit count overflows, the output signal is asserted. The output signal may thereby trigger an interrupt at the processor or set a bit that the processor can read. To restart the timer, software reloads the count register with the same or a different initial value.
참조: http://www.embedded.com/electronics-blogs/beginner-s-corner/4024440/Introduction-to-Counter-Timers


vector
http://www.keil.com/forum/6306/
https://en.wikipedia.org/wiki/Interrupt_vector_table

SFR
Special Function Register:
SFR Page: pages when reading or modifying SFRs.
SFR Page[7:0] = 00001111 (control_page)
SFR Page[7:0] = 00000000 (active_page)


PCA (Programmable Counter Array)
PCA 주요특징.
• 16-bit time base.
• Programmable clock divisor and clock source selection.
• Up to three independently-configurable channels
• 8, 9, 10, 11 and 16-bit PWM modes (edge-aligned operation).
• Frequency output mode.
• Capture on rising, falling or any edge.
• Compare function for arbitrary waveform generation.
• Software timer (internal compare) mode.
• Integrated watchdog timer.
참조: http://igotit.tistory.com/296


Push-Pull/Open Drain 출력 설정
This answer is general to processors and peripherals, and has an SRAM specific comment at the end, which is probably pertinent to your specific RAM and CPU.

Output pins can be driven in three different modes:

• open drain - a transistor connects to low and nothing else
• open drain, with pull-up - a transistor connects to low, and a resistor connects to high
• push-pull - a transistor connects to high, and a transistor connects to low (only one is operated at a time)
• Input pins can be a gate input with a:

• pull-up - a resistor connected to high
• pull-down - a resistor connected to low
• pull-up and pull-down - both a resistor connected to high and a resistor connected to low (only useful in rare cases).
참조: https://electronics.stackexchange.com/questions/28091/push-pull-open-drain-pull-up-pull-down

crossbar
참조: https://www.reddit.com/r/AskElectronics/comments/1ggdd6/what_is_the_crossbar_in_a_microcontroller_and_how/


ASCII
0x0d : carriage return (\r)
0x0a : new line ( \n)


SBIT
SFR 에 개별적으로 접근하기 위한 방법

SBIT (TI0, SFR_SCON0, 1);              // UART0 TX Interrupt Flag
SBIT (RI0, SFR_SCON0, 0);              // UART0 RX Interrupt Flag

참조: http://www.fsinc.com/reference/html/com9agk.htm


Pin Configuration
핀 구성을 도와주는 프로그램이 들어 있다.
그 툴로 셋팅을 하면 Register를 셋팅하는 코드가 나오니 그 코드를 사용하면 된다.
Config2.exe

2017년 4월 3일 월요일

Image processor

이미지 프로세서를 이해하기 위해서 Wikipedia 내용을 번역

An image processor, image processing engine, also called media processor, is a specialized digital signal processor (DSP) used for image processing in digital cameras, mobile phones or other devices.[1][2] Image processors often employ parallel computing even with SIMD or MIMD technologies to increase speed and efficiency. The digital image processing engine can perform a range of tasks. To increase the system integration on embedded devices, often it is a system on a chip with multi-core processor architecture.
이미지 프로세서(이미지 프로세싱 엔진, 그리고 미디어 프로세서로 불리는)는 디지털 카메라, 핸드폰 그리고 다른 장치들에서 사용되는 특화된 디지털 시그널 프로세서(DSP)를 말한다. 이미지 프로세서는 스피드오 효율성을 위해서 SIMD 나 MIMD 와 같은 병렬 컴퓨팅를 사용한다. 디지털 이미지 프로세싱 인진은 여러 Task 를 사용할 수 있다. 임베디드 시스템에서의 시스템 통합을 위해서, 멀티코어 프로세서 시스템 구성을 가진 칩 위에서 사용된다.


Function

Bayer transformation
The photodiodes employed in an image sensor are color-blind by nature: they can only record shades of grey. To get color into the picture, they are covered with different color filters: red, green and blue (RGB) according to the pattern designated by the Bayer filter - named after its inventor. As each photodiode records the color information for exactly one pixel of the image, without an image processor there would be a green pixel next to each red and blue pixel. (Actually, with most sensors there are two green for each blue and red diodes.)
This process, however, is quite complex and involves a number of different operations. Its quality depends largely on the effectiveness of the algorithms applied to the raw data coming from the sensor. The mathematically manipulated data becomes the photo file recorded.
이미지 센서에 사용된 포토 다이오드(감광성의 반도체 장치)는 자연에 의한 color-blind 이다: 회색 그림자만을 저장할 수 있다. 그림에 색을 넣기 위해서는, 서로 다른 Bayer Filter(만든사람 이름)로 디자인된 색 필터가 사용되어야 한다: 빨간색, 녹색 그리고 파란색(RGB). 각각의 포토 다이오드는 하나의 색 정보(RGB 중 1개) 밖에 없기 때문에 이미지 프로세서가 없다면 그냥 녹색 픽셀 옆에 파란색 그 옆에 빨간색 픽셀이 있는 것이다?(실제로는 파란색, 빨간색 하나씩에 녹색은 2개가 있다.)
하지만 이 프로세스는 꽤 복잡하며 많은 작업들이 연관되어 있다. 품질은 sensor 에서 받은 raw 데이터에 대한 알고리즘의 효과성에 달려 있다. 수학적으로 조작된 데이터는 사진 파일이 된다.

Demosaicing
As stated above, the image processor evaluates the color and brightness data of a given pixel, compares them with the data from neighboring pixels and then uses a demosaicing algorithm to produce an appropriate colour and brightness value for the pixel. The image processor also assesses the whole picture to guess at the correct distribution of contrast. By adjusting the gamma value (heightening or lowering the contrast range of an image's mid-tones) subtle tonal gradations, such as in human skin or the blue of the sky, become much more realistic.
이미지 프로세서는 픽셀에 있는 색과 밝기를 평가하고 옆에 있는 픽셀들과 비교하여 demosaicing 알고리즘을 적용하고 나면 적절한 색과 밝기를 생산해 낸다. 이미지 프로세서는 전체 사진에 대해 판단하여 정확한 대비의 분배를 추측한다. gamma 값을 조정하여(이미지의 mid-tone 대비값을 강조하거나 낮추거나 해서) 미묘한 톤의 단계적 차이를 현실감 있게(피부 및 하늘의 파란 색 등) 표현한다.
- 디지털 카메라의 모자이크 형태의 컬러필터배열(CFA)에 의해 만들어진 샘플을 풀컬러 이미지로 변환하는 것(Link)

Noise reduction
Noise is a phenomenon found in any electronic circuitry. In digital photography its effect is often visible as random spots of obviously wrong colour in an otherwise smoothly-coloured area. Noise increases with temperature and exposure times. When higher ISO settings are chosen the electronic signal in the image sensor is amplified, which at the same time increases the noise level, leading to a lower signal-to-noise ratio. The image processor attempts to separate the noise from the image information and to remove it. This can be quite a challenge, as the image may contain areas with fine textures which, if treated as noise, may lose some of their definition.
노이즈는 어느 전기적 회로에나 있는 현상이다. 디지털 사진에서 random 하게 명확하게 잘못된 값들이 관찰되게 된다. 노이즈는 온도에 따르거나 노출 시간에 따라 증가되게 된다. 이미지 센서가 증폭될 때에 높은 ISO 셋팅이 사용되면 노이즈 도 같이 증폭되게 된다. 이미지 프로세서는 이미지 정보와 노이즈를 분리하려고 시도한 뒤 노이즈를 제거한다. 이런 것은 꽤 challenge 가 될 수 있다. 이미지에서 정제된 질감을 가질 때는 노이즈로 취급되어 사라질 수도 있다.


Image sharpening
As the color and brightness values for each pixel are interpolated some image softening is applied to even out any fuzziness that has occurred. To preserve the impression of depth, clarity and fine details, the image processor must sharpen edges and contours. It therefore must detect edges correctly and reproduce them smoothly and without over-sharpening.
각 픽셀의 색과 밝기 값들이 interpolate 되어 보풀같은 것들이 일어났을 때 이미지를 부드럽게 만들어낼 때 쓰인다. depth, clarity, fine detail 의 인상을 보존하고 싶을 때, 이미지 프로세서는 에지나 윤곽을 날카롭게 한다.    그래서 에지들을 명확하게 감지하고 그것들을 부드럽게 재현하는 것 그리고 Over sharpening 하는 것이 없어야 한다.

참조: Link