Showing posts with label New Summit College. Show all posts
Showing posts with label New Summit College. Show all posts

RGB to HSV Conversion

Input: RGB
Output: HSV


Steps:
1. Input RGB.
2. Normalize the RGB values to be in the range [0, 1].
    r = R/255, g = G/255, b = B/255
3. Find the difference between max and min values.
    M = max(r,g,b), m = min(r,g,b). And, the difference Δ = M - m
4. Calculate hue H.
    If M = m = 0, then H = 0
    If M = r, then compute H = (60 * ((g – b) / Δ) + 360) % 360
    If M = g, then compute H = (60 * ((b – r) / Δ) + 120) % 360
    If M = b, then compute H = (60 * ((r – g) / Δ) + 240) % 360
5. Calculate saturation S.
    If Δ = 0, S = 0; Else, S = Δ/M
6. Calculate value V.
    V = max(r,g,b)
7. Output HSV.

8086 Program - Sum of Two Input Numbers

This is an assembly language program for 8086 microprocessor in which user gives two data as input and the program finds its sum. Here, only one digit data is permitted. What we input here is in ASCII value, so we subtract by 48 before addition; and add by 48 after addition so that we can properly display the value in decimal value.

.model small 
.data
str1 db "Enter first number: $"
str2 db 13,10,"Enter second number: $"
str3 db 13,10,"The sum is: $"
.code
main proc
    mov ax,@data
    mov ds,ax
    lea dx,str1
    mov ah,9
    int 21h
    mov ah,1
    int 21h
    mov bl,al
    lea dx,str2
    mov ah,9
    int 21h
    mov ah,1
    int 21h
    mov bh,al
    sub bh,48
    sub bl,48
    lea dx,str3
    mov ah,9
    int 21h   
    add bh,bl
    add bh,48
    mov dl,bh
    mov ah,2
    int 21h
    mov ah,4Ch
    int 21h
main endp
end