The MASM Forum

General => The Campus => Topic started by: Grincheux on December 08, 2015, 05:18:30 AM

Title: I would like a lesson
Post by: Grincheux on December 08, 2015, 05:18:30 AM
Just title!

I am coding a program  that modifies colors in an image.

xRGB - 32 bits

What are the MMX or SSE or xxx that I could you use.
I don't know these instruction, perhaps some of them could help me,.... to be faster


jmp @Loop

; **********************************************************************************
ALIGN 16
; **********************************************************************************

@Loop :

mov eax,[edi]
and eax,00ffffffh
mov edx,eax
mov ebx,eax
shr edx,8
shr ebx,16
and eax,000000ffh
and edx,000000ffh
and ebx,000000ffh
add eax,ebx
add eax,edx
xor edx,edx
mov ebx,3
div bx
mov ah,al
shl eax,8
mov al,ah
mov [edi],eax
add edi,SIZEOF DWord
sub ecx,SIZEOF DWord
jnz @Loop

ret
Effect_Grey_Minimum ENDP


This is an example of what I do.
This is a grey conversion based on the average of REG / GREEN / BLUE
I would like to optimize it.

JJ2007 vexed me with my very slow program. I laugh.
Title: Re: I would like a lesson
Post by: jj2007 on December 08, 2015, 06:01:40 AM
Quote from: Grincheux on December 08, 2015, 05:18:30 AM
JJ2007 vexed me with my very slow program. I laugh.

Sorry, no bad intentions :P

Have a look specifically at
pshuf*
andps
movlps, movups
pcmpeqb
Title: Re: I would like a lesson
Post by: dedndave on December 08, 2015, 06:35:16 AM
a little work on your algorithm is probably in order

avoid the use of DIV when possible
in the case of division by 3, it is easily avoided
you can use "multiply-to-divide" and it will be much faster

however, the gray-scale conversion can be performed another way...

Y = .587G + .299R + .114B

so, select scaling constants that will cause a total of 0FF_FFFFFFFFh and accumulate in EDX:EAX
when you are done, DL will have the luminance byte value without division   :biggrin:

Y = (LG + MR + NB) / 4294967296
L + M + N = FFFFFFFFFF / FF = 4311810305
L = .587 * 4311810305 = 2531032649
M = .299 * 4311810305 = 1289231281
N = .114 * 4311810305 = 491546375


so....

MOVZX EAX,byte ptr [blue]
MUL by 491546375
MOV ESI,EAX
MOV EDI,EDX

MOVZX EAX,byte ptr [red]
MUL by 1289231281
ADD ESI,EAX
ADC EDI,EDX

MOVZX EAX,byte ptr [green]
MUL by 2531032649
ADD EAX,ESI
ADC EDX,EDI

;DL = luminance byte


now, you could do this...

MOV byte ptr [blue],DL
MOV byte ptr [green],DL
MOV byte ptr [red],DL


but, faster, MUL DL by 10101h and write all 3 bytes as a dword
Title: Re: I would like a lesson
Post by: Grincheux on December 08, 2015, 06:40:42 AM
For Gray conversion there is your formula that I know but there are three others :

Minimum of all the components
Maximum
Average

That's all grey
Title: Re: I would like a lesson
Post by: dedndave on December 08, 2015, 06:44:47 AM
that's a poor shortcut

use the equation i posted - lol
Title: Re: I would like a lesson
Post by: Grincheux on December 08, 2015, 06:49:24 AM
JJ2007 thanks for your docs but I already have it.
I have searched width Google but they just say what the instruction does. One line by instruction!
Many instructions use floating points but me it is integers that I have. Is it a problem?
https://www.csie.ntu.edu.tw/~cyy/courses/assembly/docs/ch11_MMX.pdf (https://www.csie.ntu.edu.tw/~cyy/courses/assembly/docs/ch11_MMX.pdf) This is the best I have found.
Many have gas syntax.
Title: Re: I would like a lesson
Post by: jj2007 on December 08, 2015, 07:27:53 AM
Quote from: Grincheux on December 08, 2015, 06:49:24 AM
JJ2007 thanks for your docs but I already have it.

It's the best I found so far. The original Intel manuals are too big and detailed for my taste.

QuoteMany instructions use floating points but me it is integers that I have. Is it a problem?

No. SSE instructions that load, save or make bitwise operations do not distinguish between float, double or integer.
Btw avoid mmx, go for xmm. More bits and no conflict with the FPU.
Title: Re: I would like a lesson
Post by: Grincheux on December 08, 2015, 07:31:21 AM
For dividing, I know that it is very slow. I suggested an other way (http://masm32.com/board/index.php?topic=4886.0 (http://masm32.com/board/index.php?topic=4886.0)).
Many people have a formula for grey conversion. Difficult to make the choice.

Grey = 0.2125 Rouge + 0.7154 Vert + 0.0721 Bleu
Grey = 0.299 Rouge + 0.587 Vert + 0.114 Bleu

A site than can help in research http://www.tutorialspoint.com/dip/pdf/Gray_Level_Transformations.pdf (http://www.tutorialspoint.com/dip/pdf/Gray_Level_Transformations.pdf)
Title: Re: I would like a lesson
Post by: Siekmanski on December 08, 2015, 12:21:01 PM
Hi Grincheux,

Here are 4 methods:

1) The lightness method:
   Averages the most prominent and least prominent colors: (max(R, G, B) + min(R, G, B)) / 2

2) The average method:
   Averages the values: (R + G + B) / 3

3) Colorimetric method:
   It forms a weighted average to account for human perception.
   Luminosity is: (R * 0.2126) + (G * 0.7152) + (B * 0.0722)

4) Luma coding method:
   This is how we perceive colors from TV's monitors etc.
   Luma is: (R * 0.299) + (G * 0.587) + (B * 0.114)


This is the SSE version of the average method.
It processes four 32 bit pixels at once.

EDIT: inserted roundup code to prevent overflow.


.data
align 16
div3 equ 256/3
MagicDiv3   dd div3,div3,div3,div3
ByteMask    dd 000000ffh,000000ffh,000000ffh,000000ffh
RoundUp     dd 3,3,3,3

rgb_data    db 255,123,11,0, 210,33,77,0, 239,111,178,0, 99,88,22,0
Average     dd 0,0,0,0

.code
    movaps  xmm0,oword ptr rgb_data
    movaps  xmm1,oword ptr ByteMask
    movaps  xmm2,xmm0   ; __ B3 G3 R3,  __ B2 G2 R2,  __ B1 G1 R1,  __ B0 G0 R0
    psrld   xmm0,8      ; __ __ B3 G3,  __ __ B2 G2,  __ __ B1 G1,  __ __ B0 G0
    movaps  xmm3,xmm0   ; __ __ B3 G3,  __ __ B2 G2,  __ __ B1 G1,  __ __ B0 G0
    psrld   xmm0,8      ; __ __ __ B3,  __ __ __ B2,  __ __ __ B1,  __ __ __ B0
    pand    xmm2,xmm1   ; __ __ __ R3,  __ __ __ R2,  __ __ __ R1,  __ __ __ R0
    pand    xmm3,xmm1   ; __ __ __ G3,  __ __ __ G2,  __ __ __ G1,  __ __ __ G0
    pand    xmm0,xmm1   ; __ __ __ B3,  __ __ __ B2,  __ __ __ B1,  __ __ __ B0
    paddd   xmm0,xmm3   ; B + G
    paddd   xmm0,xmm2   ; B + G + R
    paddd   xmm0,oword ptr RoundUp
    pmullw  xmm0,oword ptr MagicDiv3
    psrld   xmm0,8      ; __ __ __ A3,  __ __ __ A2,  __ __ __ A1,  __ __ __ A0
    movaps  xmm1,xmm0
    movaps  xmm2,xmm0
    pslld   xmm1,8      ; __ __ A3 __,  __ __ A2 __,  __ __ A1 __,  __ __ A0 __
    pslld   xmm2,16     ; __ A3 __ __,  __ A2 __ __,  __ A1 __ __,  __ A0 __ __
    pxor    xmm0,xmm1   ; __ __ A3 A3,  __ __ A2 A2,  __ __ A1 A1,  __ __ A0 A0
    pxor    xmm0,xmm2   ; __ A3 A3 A3,  __ A2 A2 A2,  __ A1 A1 A1,  __ A0 A0 A0
    movaps  oword ptr Average,xmm0 ; A3=130 A2=107 A1=177 A0=70


Marinus
Title: Re: I would like a lesson
Post by: dedndave on December 08, 2015, 11:46:28 PM
Marinus...

1) this method makes no sense for individual-pixel conversion   :redface:

2) this method is a poor shortcut - simpler, yes - faster, probably not

3) this method is a color-contrast equation, used primarily for contrasting text comparisons

4) this is the proper method for converting to gray-shades
it is how we perceive light (not just from TVs, research human eye, rods and cones)
it is used for all sorts of things, not just simple image conversion (astronomy, facial recognition, bio-medical, etc)

no matter which method you use, an image can be created which will be totally ambiguous when converted
in other words, the 3 image colors may contrast,
but when converted to gray-shades, the entire image is a single shade
over a wide variety of images, the later method will perform the best
Title: Re: I would like a lesson
Post by: dedndave on December 09, 2015, 12:20:10 AM
give this a try
you won't be disappointed with speed or results

the _lpBmpData argument is a pointer to the image data (after the header)
it will be fastest if this address is 4-aligned

Bmp2Gray32 PROTO :DWORD,:DWORD,:LPVOID

Bmp2Gray32 PROC USES EBX ESI EDI _dwWidth:DWORD,_dwHeight:DWORD,_lpBmpData:LPVOID

    mov     eax,_dwWidth
    push    ebp
    mul     _dwHeight
    mov     ebx,_lpBmpData
    xchg    eax,ebp
    .repeat
        movzx   eax,byte ptr [ebx]           ;EAX = blue
        mov     ecx,491546375
        mul     ecx
        xchg    eax,esi
        mov     edi,edx
        movzx   eax,byte ptr [ebx+1]         ;EAX = green
        mov     ecx,2531032649
        mul     ecx
        add     esi,eax
        adc     edi,edx
        movzx   eax,byte ptr [ebx+2]         ;EAX = red
        mov     ecx,1289231281
        mul     ecx
        add     eax,esi
        adc     edx,edi
        mov     eax,10101h
        mul     edx
        or      eax,0FF000000h               ;opacity = 255
        mov     [ebx],eax
        dec     ebp
        lea     ebx,[ebx+4]
    .until ZERO?
    pop     ebp
    ret

Bmp2Gray32 ENDP
Title: Re: I would like a lesson
Post by: FORTRANS on December 09, 2015, 01:36:36 AM
Hi Dave,

Quote from: dedndave on December 08, 2015, 11:46:28 PM
1) this method makes no sense for individual-pixel conversion

   At first glance, I would tend to agree.  I may try it out though,
if I get curious.

Quote2) this method is a poor shortcut - simpler, yes - faster, probably not

   But it is commonly used.

Quote3) this method is a color-contrast equation, used primarily for contrasting text comparisons

   Based on the reference I use, this is closest to using S.M.P.T.E.
RGB primaries and YIQ or YUV intensity encoding.  The numbers
in his table are 0.212, 0.701, and 0.087.  These are close to the
numbers they posted.  Essentially an update of the N.T.S.B. values
to more modern phosphors (and so forth).

Quote4) this is the proper method for converting to gray-shades
it is how we perceive light (not just from TVs, research human eye, rods and cones)
it is used for all sorts of things, not just simple image conversion (astronomy, facial recognition, bio-medical, etc)

   This is using N.T.S.B. RGB primaries and the YIQ intensity channel.
Often used, but uses old phosphor emission curves.  This was
developed for color television transmission and reception in the U.S..

   If I look up in the table the C.I.E. colorimetric (actually "Spectral
Primary Color Coordinate System") RGB primarys and its YIQ
transformation, its factors are 0.177, 0.813, and 0.011.
This is a bit odd, as it is using tristimulus values of a "Standard
Observer" and TV transmission transforms.  But it also brings
up the old fast color to gray algorithm, Gray = Green.  Remember
that one from "the good old days"?

   In practice, the N.T.S.B. YIQ intensity transformation works
well on most common images.  YMMV.

Regards,

Steve N.
Title: Re: I would like a lesson
Post by: Grincheux on December 09, 2015, 02:42:44 AM
Quote
the _lpBmpData argument is a pointer to the image data (after the header)
it will be fastest if this address is 4-aligned

The BITMAPINFO Structure is 44 bytes length so I suppose it is aligned.


.Data
ALIGN 4

TabDiv3 Byte 0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,5
Byte 5,5,6,6,6,7,7,7,8,8,8,9,9,9,10,10
Byte 10,11,11,11,12,12,12,13,13,13,14,14,14,15,15,15
Byte 16,16,16,17,17,17,18,18,18,19,19,19,20,20,20,21
Byte 21,21,22,22,22,23,23,23,24,24,24,25,25,25,26,26
Byte 26,27,27,27,28,28,28,29,29,29,30,30,30,31,31,31
Byte 32,32,32,33,33,33,34,34,34,35,35,35,36,36,36,37
Byte 37,37,38,38,38,39,39,39,40,40,40,41,41,41,42,42
Byte 42,43,43,43,44,44,44,45,45,45,46,46,46,47,47,47
Byte 48,48,48,49,49,49,50,50,50,51,51,51,52,52,52,53
Byte 53,53,54,54,54,55,55,55,56,56,56,57,57,57,58,58
Byte 58,59,59,59,60,60,60,61,61,61,62,62,62,63,63,63
Byte 64,64,64,65,65,65,66,66,66,67,67,67,68,68,68,69
Byte 69,69,70,70,70,71,71,71,72,72,72,73,73,73,74,74
Byte 74,75,75,75,76,76,76,77,77,77,78,78,78,79,79,79
Byte 80,80,80,81,81,81,82,82,82,83,83,83,84,84,84,85
Byte 85,85,86,86,86,87,87,87,88,88,88,89,89,89,90,90
Byte 90,91,91,91,92,92,92,93,93,93,94,94,94,95,95,95
Byte 96,96,96,97,97,97,98,98,98,99,99,99,100,100,100,101
Byte 101,101,102,102,102,103,103,103,104,104,104,105,105,105,106,106
Byte 106,107,107,107,108,108,108,109,109,109,110,110,110,111,111,111
Byte 112,112,112,113,113,113,114,114,114,115,115,115,116,116,116,117
Byte 117,117,118,118,118,119,119,119,120,120,120,121,121,121,122,122
Byte 122,123,123,123,124,124,124,125,125,125,126,126,126,127,127,127
Byte 128,128,128,129,129,129,130,130,130,131,131,131,132,132,132,133
Byte 133,133,134,134,134,135,135,135,136,136,136,137,137,137,138,138
Byte 138,139,139,139,140,140,140,141,141,141,142,142,142,143,143,143
Byte 144,144,144,145,145,145,146,146,146,147,147,147,148,148,148,149
Byte 149,149,150,150,150,151,151,151,152,152,152,153,153,153,154,154
Byte 154,155,155,155,156,156,156,157,157,157,158,158,158,159,159,159
Byte 160,160,160,161,161,161,162,162,162,163,163,163,164,164,164,165
Byte 165,165,166,166,166,167,167,167,168,168,168,169,169,169,170,170
Byte 170,171,171,171,172,172,172,173,173,173,174,174,174,175,175,175
Byte 176,176,176,177,177,177,178,178,178,179,179,179,180,180,180,181
Byte 181,181,182,182,182,183,183,183,184,184,184,185,185,185,186,186
Byte 186,187,187,187,188,188,188,189,189,189,190,190,190,191,191,191
Byte 192,192,192,193,193,193,194,194,194,195,195,195,196,196,196,197
Byte 197,197,198,198,198,199,199,199,200,200,200,201,201,201,202,202
Byte 202,203,203,203,204,204,204,205,205,205,206,206,206,207,207,207
Byte 208,208,208,209,209,209,210,210,210,211,211,211,212,212,212,213
Byte 213,213,214,214,214,215,215,215,216,216,216,217,217,217,218,218
Byte 218,219,219,219,220,220,220,221,221,221,222,222,222,223,223,223
Byte 224,224,224,225,225,225,226,226,226,227,227,227,228,228,228,229
Byte 229,229,230,230,230,231,231,231,232,232,232,233,233,233,234,234
Byte 234,235,235,235,236,236,236,237,237,237,238,238,238,239,239,239
Byte 240,240,240,241,241,241,242,242,242,243,243,243,244,244,244,245
Byte 245,245,246,246,246,247,247,247,248,248,248,249,249,249,250,250
Byte 250,251,251,251,252,252,252,253,253,253,254,254,254,255,255,255

ALIGN 4

TabRed Byte 0,0,0,0,1,1,1,2,2,2,2,3,3,3,4,4
Byte 4,5,5,5,5,6,6,6,7,7,7,8,8,8,8,9
Byte 9,9,10,10,10,11,11,11,11,12,12,12,13,13,13,14
Byte 14,14,14,15,15,15,16,16,16,17,17,17,17,18,18,18
Byte 19,19,19,20,20,20,20,21,21,21,22,22,22,23,23,23
Byte 23,24,24,24,25,25,25,25,26,26,26,27,27,27,28,28
Byte 28,28,29,29,29,30,30,30,31,31,31,31,32,32,32,33
Byte 33,33,34,34,34,34,35,35,35,36,36,36,37,37,37,37
Byte 38,38,38,39,39,39,40,40,40,40,41,41,41,42,42,42
Byte 43,43,43,43,44,44,44,45,45,45,46,46,46,46,47,47
Byte 47,48,48,48,49,49,49,49,50,50,50,51,51,51,51,52
Byte 52,52,53,53,53,54,54,54,54,55,55,55,56,56,56,57
Byte 57,57,57,58,58,58,59,59,59,60,60,60,60,61,61,61
Byte 62,62,62,63,63,63,63,64,64,64,65,65,65,66,66,66
Byte 66,67,67,67,68,68,68,69,69,69,69,70,70,70,71,71
Byte 71,72,72,72,72,73,73,73,74,74,74,75,75,75,75,76

ALIGN 4

TabGreen Byte 2,2,3,3,3,4,4,4,4,4,4,5,5,5,5,5
Byte 5,6,6,6,7,7,7,7,7,7,8,8,8,8,8,8
Byte 9,9,9,9,9,9,10,10,10,11,11,11,11,11,11,12
Byte 12,12,12,12,12,13,13,13,14,14,14,14,14,14,15,15
Byte 15,15,15,15,16,16,16,17,17,17,17,17,17,18,18,18
Byte 18,18,18,19,19,19,19,19,19,20,20,20,21,21,21,21
Byte 21,21,22,22,22,22,22,22,23,23,23,24,24,24,24,24
Byte 24,25,25,25,25,25,25,26,26,26,26,26,26,27,27,27
Byte 28,28,28,28,28,28,29,29,29,29,29,29,30,30,30,31
Byte 31,31,31,31,31,32,32,32,32,32,32,33,33,33,34,34
Byte 34,34,34,34,35,35,35,35,35,35,36,36,36,36,36,36
Byte 37,37,37,38,38,38,38,38,38,39,39,39,39,39,39,40
Byte 40,40,41,41,41,41,41,41,42,42,42,42,42,42,43,43
Byte 43,44,44,44,44,44,44,45,45,45,45,45,45,46,46,46
Byte 46,46,46,47,47,47,48,48,48,48,48,48,49,49,49,49
Byte 49,49,50,50,50,51,51,51,51,51,51,52,52,52,52,52

ALIGN 4

TabBlue Byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Byte 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Byte 1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2
Byte 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
Byte 2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3
Byte 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
Byte 3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4
Byte 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
Byte 4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5
Byte 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
Byte 5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6
Byte 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6
Byte 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
Byte 7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8
Byte 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
Byte 8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9

.Code

; ==================================================================================
ALIGN 16
; ==================================================================================

Effect_Grey_601 PROC __lpImageBuffer:LPBYTE

push edi

mov edi,__lpImageBuffer
mov ecx,[edi].BITMAPINFO.bmiHeader.biSizeImage
add edi,SIZEOF BITMAPINFO
jmp @Loop

; **********************************************************************************
ALIGN 16
; **********************************************************************************

@Loop :

mov eax,[edi]
push eax
movzx edx,ah
movzx eax,al
mov dl,Byte Ptr [OFFSET TabGreen + edx]
mov al,Byte Ptr [OFFSET TabBlue + eax]
add eax,edx
pop edx
shr edx,16
movzx edx,dl
mov dl,Byte Ptr [OFFSET TabRed + edx]
add eax,edx
movzx eax,al

mov ah,al
shl eax,8
mov al,ah

mov [edi],eax

add edi,SIZEOF DWord
sub ecx,SIZEOF DWord
jnz @Loop

pop edi

ret
Effect_Grey_601 ENDP


TabBlue, TabGreen and TabRed are the values for the coefficients.

Thanks evryone for your help. I learn a lot of things.
Title: Re: I would like a lesson
Post by: Siekmanski on December 09, 2015, 06:55:26 AM
Dave...

I agree that the " (R * 0.299) + (G * 0.587) + (B * 0.114) " is the best routine for gray-scale conversion.  ;)
I just summed up the other methods I've heard of.

Grincheux asked: What are the MMX or SSE or xxx that I could use.
So I translated the average method routine he posted to SSE.
Title: Re: I would like a lesson
Post by: Grincheux on December 09, 2015, 07:31:05 AM
Super. That what I expected.
Thank you Siekmanski  :eusa_boohoo:.
Title: Re: I would like a lesson
Post by: Grincheux on December 10, 2015, 12:49:41 AM
I come back with my grey function.


Effect_Grey_Average      PROC   __lpImageBuffer:LPBYTE


;                  LOCAL   time,time_low,time_high:DWORD
;                  LOCAL   mhz:DWORD ; 150000000      ;// 150 MHz processor;
;
;                  mov      mhz,150000000
;                  rdtsc                        ;// Read time stamp to EAX
;                  mov      time_low, eax
;                  mov      time_high, edx
;
                  push   edi


                  mov      edi,__lpImageBuffer
                  mov      ecx,[edi].BITMAPINFO.bmiHeader.biSizeImage
                  add      edi,SIZEOF BITMAPINFO
                  jmp      @Loop

;   **********************************************************************************
                  ALIGN   16
;   **********************************************************************************

@Loop :

                  prefetch   [edi]

                  movzx   eax,Byte Ptr [edi + 2]               ; Red
                  movzx   edx,Byte Ptr [edi + 1]               ; Green
                  add      eax,edx
                  mov      dl,Byte Ptr [edi + 0]               ; Blue
                  add      eax,edx
                  mov      al,Byte Ptr [OFFSET TabDiv3 + eax]

                  mov      ah,al
                  shl      eax,8
                  mov      al,ah

                  mov      [edi],eax

                  add      edi,SIZEOF DWord
                  sub      ecx,SIZEOF DWord
                  jnz      @Loop

                  pop      edi

;                  rdtsc
;                  sub      eax,time_low         ;// Find the difference
;                  sub      edx,time_high
;                  div      mhz                  ;// Unsigned divide EDX:EAX by mhz
;                  mov      time,eax

                  ret
Effect_Grey_Average      ENDP

Do I use it correctly? : prefetch   [edi]
I would like to use Siekmanski's function but there are compile errors for the registers xmm0...
                  .686p                     ; create 32 bit code
                  .MMX                      ; enable MMX instructions
                  .XMM                      ; enable SSE instructions
                  .MODEL flat, stdcall      ; 32 bit memory model
                  OPTION casemap :none      ; case sensitive

Title: Re: I would like a lesson
Post by: jj2007 on December 10, 2015, 01:20:20 AM
Quote from: Grincheux on December 10, 2015, 12:49:41 AMI would like to use Siekmanski's function but there are compile errors for the registers xmm0...
                  .686p                     ; create 32 bit code
                  .MMX                      ; enable MMX instructions
                  .XMM                      ; enable SSE instructions
                  .MODEL flat, stdcall      ; 32 bit memory model
                  OPTION casemap :none      ; case sensitive

Use JWasm or AsmC. The old ML 6.14 doesn't understand SSE2.
Title: Re: I would like a lesson
Post by: Siekmanski on December 10, 2015, 06:48:22 AM
You can try to include these SSE2 macros for MASM 6.14 by daydreamer aka Magnus Svensson.
Title: Re: I would like a lesson
Post by: hutch-- on December 10, 2015, 06:54:05 AM
Philippe,

Just get a later version of ML.EXE. My Win7 64 SDK had version 10 in it and it handles most of the later SSE instructions.
Title: Re: I would like a lesson
Post by: Grincheux on December 10, 2015, 01:22:39 PM
Does this instruction is a good idea for being faster?

Quoteprefetch   [edi]
Title: Re: I would like a lesson
Post by: Grincheux on December 10, 2015, 01:28:52 PM
Thanks Hutch and Siekmanski.


I have updated ML.exe rather than using JWasm.

Title: Re: I would like a lesson
Post by: hutch-- on December 10, 2015, 02:45:43 PM
Philippe,

From my experience the instruction (hint),

prefetch   [edi]


was only useful on a PIV and then it was hard to clock the difference.
Title: Re: I would like a lesson
Post by: Grincheux on December 10, 2015, 04:15:36 PM
(http://phrio.biz/download/Grey.jpg)


It's ok with Siekmanski's instructions.
I have been obliged to change many things.
The buffer was aligned to a multiple of 4, pgm crashed :eusa_naughty:
It made changes to align it at a multiple of 16 and that' ok  :greenclp:
I don't understand why dividing by 85 (256 / 3) div3 gives a good result result on grey conversion.



div3 EQU 256/3
;MagicDiv3            DWord   0aaaaaaabh,0aaaaaaabh,0aaaaaaabh,0aaaaaaabh
MagicDiv3            DWord   div3,div3,div3,div3
ByteMask            DWord   000000ffh,000000ffh,000000ffh,000000ffh
RoundUp               DWord   3,3,3,3


                  .Code
;   -------------------------------------------------------------------------------------------------------------


Effect_0014            PROC   __lpImageBuffer:LPBYTE
                  LOCAL   _Counter128:DWord


                  push         edi


                  mov      edi,__lpImageBuffer
                  mov      ecx,[edi].IMAGEINFOS.Bmi.bmiHeader.biSizeImage
                  lea      edi,[edi].IMAGEINFOS.Start


                  mov      edx,ecx
                  shr      edx,4                  ; SizeImage / 128
                  push      edx
                  shl      edx,4
                  sub      ecx,edx                  ; SizeImage - (SizeImage / 128)
                  pop      eax
                  jmp      @Loop_128


;   **********************************************************************************
                  ALIGN   16
;   **********************************************************************************


@Loop_128 :


                  movaps   xmm0,OWord Ptr [edi]
                  movaps   xmm1,OWord Ptr ByteMask
                  movaps   xmm2,xmm0   ; __ B3 G3 R3,  __ B2 G2 R2,  __ B1 G1 R1,  __ B0 G0 R0
                  psrld   xmm0,8      ; __ __ B3 G3,  __ __ B2 G2,  __ __ B1 G1,  __ __ B0 G0
                  movaps   xmm3,xmm0   ; __ __ B3 G3,  __ __ B2 G2,  __ __ B1 G1,  __ __ B0 G0
                  psrld      xmm0,8      ; __ __ __ B3,  __ __ __ B2,  __ __ __ B1,  __ __ __ B0
                  pand      xmm2,xmm1   ; __ __ __ R3,  __ __ __ R2,  __ __ __ R1,  __ __ __ R0
                  pand      xmm3,xmm1   ; __ __ __ G3,  __ __ __ G2,  __ __ __ G1,  __ __ __ G0
                  pand         xmm0,xmm1   ; __ __ __ B3,  __ __ __ B2,  __ __ __ B1,  __ __ __ B0
                  paddd   xmm0,xmm3   ; B + G
                  paddd   xmm0,xmm2   ; B + G + R
                  paddd   xmm0,OWord Ptr RoundUp
                  pmullw   xmm0,OWord Ptr MagicDiv3
                  psrld      xmm0,8      ; __ __ __ A3,  __ __ __ A2,  __ __ __ A1,  __ __ __ A0
                  movaps   xmm1,xmm0
                  movaps   xmm2,xmm0
                  pslld   xmm1,8      ; __ __ A3 __,  __ __ A2 __,  __ __ A1 __,  __ __ A0 __
                  pslld   xmm2,16     ; __ A3 __ __,  __ A2 __ __,  __ A1 __ __,  __ A0 __ __
                  pxor   xmm0,xmm1   ; __ __ A3 A3,  __ __ A2 A2,  __ __ A1 A1,  __ __ A0 A0
                  pxor   xmm0,xmm2   ; __ A3 A3 A3,  __ A2 A2 A2,  __ A1 A1 A1,  __ A0 A0 A0
                  movaps   OWord Ptr [edi],xmm0 ; A3=130 A2=107 A1=177 A0=70;


                  add      edi,4 * (SIZEOF DWord)
                  sub      eax,1
                  jnz      @Loop_128


                  sub      ecx,0
                  jz      @EndLoop


@Loop :


                  prefetch   [edi]


                  movzx   eax,Byte Ptr [edi + 2]               ; Red
                  movzx   edx,Byte Ptr [edi + 1]               ; Green
                  add      eax,edx
                  mov      dl,Byte Ptr [edi + 0]               ; Blue
                  add      eax,edx
                  mov      al,Byte Ptr [OFFSET TabDiv3 + eax]


                  mov      ah,al
                  shl      eax,8
                  mov      al,ah

                  mov      [edi],eax

                  add      edi,SIZEOF DWord
                  sub      ecx,SIZEOF DWord
                  jnz      @Loop

@EndLoop :

                  pop      edi

                  ret
Effect_0014            ENDP


[/code]
Title: Re: I would like a lesson
Post by: Siekmanski on December 10, 2015, 06:33:15 PM
Quote from: Grincheux on December 10, 2015, 04:15:36 PM
I don't understand why dividing by 85 (256 / 3) div3 gives a good result result on grey conversion.

To do a multiplication instead of a division by 3:

MagicDiv3 = 256/3 = 85
color white = 255,255,255 ( RGB )
R+G+B = 255+255+255 = 765
765+3=768 (+3 for round up)

average = 768*85/256 = 255

        paddd   xmm0,xmm3   ; B + G
        paddd   xmm0,xmm2   ; B + G + R
        paddd   xmm0,OWord Ptr RoundUp   ; +3
        pmullw  xmm0,OWord Ptr MagicDiv3  ; *85
        psrld     xmm0,8  ; /256
Title: Re: I would like a lesson
Post by: dedndave on December 11, 2015, 04:01:38 AM
did you go to Arizona State University ?   :biggrin:
Title: Re: I would like a lesson
Post by: Siekmanski on December 11, 2015, 05:35:59 AM
I made a wrong post sorry...
Title: Re: I would like a lesson
Post by: Grincheux on December 11, 2015, 07:20:19 AM
Arizona State University Cheerleaders
(https://coedmagazine.files.wordpress.com/2015/08/asu-cheerleaders1.jpg?quality=88&w=656)
Title: Re: I would like a lesson
Post by: Siekmanski on December 11, 2015, 07:33:26 AM
Rather see those girls in full color than in grayscale.  :biggrin:
Title: Re: I would like a lesson
Post by: GoneFishing on December 11, 2015, 07:38:00 AM
You should use  Lena  (https://en.wikipedia.org/wiki/Lenna) for image processing  ;)
Title: Re: I would like a lesson
Post by: hutch-- on December 11, 2015, 07:42:17 AM
Guys, one favour here, while I think pretty girls are wonderful things, if the forum starts to get titz 'n arse images posted then it effects those folks who clock in from work where they likely have a porn filter. Just keep it to pretty faces and it does not come back at me.
Title: Re: I would like a lesson
Post by: Grincheux on December 11, 2015, 04:54:34 PM
ok
Title: Re: I would like a lesson
Post by: FORTRANS on December 12, 2015, 06:20:50 AM
Hi,

Quote from: Siekmanski on December 08, 2015, 12:21:01 PM
Here are 4 methods:

1) The lightness method:
   Averages the most prominent and least prominent colors: (max(R, G, B) + min(R, G, B)) / 2

   I have not seen that used, so I coded it up and ran some tests.
For many images it performs about the same as the standard
gray scale algorithm.  But for images that contain areas that are
a primary (red, blue, green) or secondary (magenta, yellow, cyan)
color the results are quite different.  It was easier to code though.

Cheers,

Steve N.
Title: Re: I would like a lesson
Post by: dedndave on December 12, 2015, 07:22:09 AM
if you want to compare different methods, use an image that has a wide range of colors
Title: Re: I would like a lesson
Post by: dedndave on December 12, 2015, 07:24:54 AM
i used an old version of PicView to convert to gray shades
i don't know if that's good or bad - lol
it looks right to me   :P
Title: Re: I would like a lesson
Post by: guga on December 21, 2015, 02:57:14 AM
About algorithms for image processing. I created some of them for convert different colorspaces. If someone needs it, let me know and i´ll post it here or create a proper thread for that.

About new algorithms, there are some that are used in particle physics that may help on regular software. For example, the approach describe here "Rapid, accurate particle tracking by calculation of radial symmetry centers" http://physics-server.uoregon.edu/~raghu/particle_tracking.html is deeply interesting. Maybe this can be adapted for normal image processing as a better enchantment method.

Didn´t analyzed yet. and honestly, i didn´t understood the math evolved. There have being more then 20 years since i saw those math notations  :greensml: m, Iji , Sum, integrals etc...
Title: Re: I would like a lesson
Post by: Grincheux on December 21, 2015, 03:44:01 AM
That would be interesting.
Have you formulas for detecting edge, like soebel?
Title: Re: I would like a lesson
Post by: guga on December 24, 2015, 06:43:21 AM
I guess i have them. Not sure if i ported to asm yet, but i have some of them in C. If you want i can post it for you or translate to Assembly later.
Title: Re: I would like a lesson
Post by: Grincheux on December 24, 2015, 06:55:11 AM
I prefer they are translated to asm.
I don't know very well mathematics. When I was 15 I prefered to go on submarines rather than in school!
Title: Re: I would like a lesson
Post by: FORTRANS on December 24, 2015, 09:09:59 AM
Hi,

   I just checked, and I wrote a Sobel filter in 1992.  I rewrote it
somewhat in 2009 as I had forgotten how the code worked, and
my programming style had changed somewhat.  It is 16-bit code
for an eight bit monochrome image.  So if you are really wanting
a Sobel filter, I can post the code later.

   At the time I was apparently playing with various filters, mostly
variations on high pass filtering.  The Sobel was part of an
enhancement algorithm in "Digital Image Processing", first edition,
by William K. Pratt.  He dropped that discussion in the second
edition.

   Maybe someone here has a 32-bit version they would share.

Regards,

Steve N.
Title: Re: I would like a lesson
Post by: Grincheux on December 24, 2015, 03:44:02 PM
Thx FORTRANS, I accept.
Title: Re: I would like a lesson
Post by: guga on December 24, 2015, 05:30:26 PM
For grey converton, here are some i made


;;
    RGBtoGray series v 1.0

    ______________________________________________________________________________________________________________________________
   
    This function converts a colored RGB to grayscalevalue value (from 0 to 255). Grayscale images are represents as shades of gray
    by using luminance Y, given by: Y = 0.298912 × R + 0.586611 × G + 0.114478 × B.
   
    Colors are converted to grey in four ways.  The classic formula is "luma", using the same ratios used by a B&W TV.
    Modern color monitors have different phosphors and respond differently, giving an RGB to grey conversion called "Luminance".
    Some graphics programs use an extremely simplistic "average" method, which is conceptually simple but doesn't match real world response of anything.
   
    Grey Mode   Red         Green       Blue        Format Recommendation (Color Space)
    luma        0.298912    0.586611    0.114478    Rec.601/CCIR601, ITU-R Rec.624-4 System B G, SMPTE 170M.525/59.94/2:1, 625/50/2:1, 1250/50/2:1,
                                                    525/59.94/2:1, 625/50/2:1, 1250/50/2:1
    Luminance   0.212671    0.715160    0.072169    ITU-R BT.709/Rec.709 (HDTV commonly usage).1125/60/2:1, 720/60/1:1,
                                                    1920 x 1080 (SMPTE 274M), 1280 x 720 (SMPTE 296M)
                0.212       0.701       0.087       SMPTE 240M (1125/60/2:1)
    average     0.333333    0.333333    0.333333
   
   
    I released 3 different convertion functions accordying to the format recommendation.
    Each one of them have the same functionality, just variying the resultanting value due to the target device.
   
    RGBtoGray_Rec601 ; common use for regular TV, PCs etc
    RGBtoGray_Rec709 ; usage on HDTV
    RGBtoGray_SMPTE240 ; some HDTV are using this.
    ______________________________________________________________________________________________________________________________


    Members:
   
        Red: (in) A Dword variable that represents the Red Color. It can be any positive value from 0 to 255.
       
        Green: (in) A Dword variable that represents the Red Color. It can be any positive value from 0 to 255.
   
        Blue: (in) A Dword variable that represents the Red Color. It can be any positive value from 0 to 255.
   
    ______________________________________________________________________________________________________________________________

    Examples of usage:

        1)
            call RGBtoGray 243, 221, 180

        2)

            [InputRed: D$ 200
                InputGreen: D$ 12
                InputBlue: D$ 158]
           
            call RGBtoGray D$InputRed, D$InputGreen, D$InputBlue



    ______________________________________________________________________________________________________________________________

    Returned Value:
        The resultant gray value will be returned in eax. It can be a integer value from 0 to 255

    ______________________________________________________________________________________________________________________________
   
    Remarks:
   
        The convertion to grayscale may be a bit confusing, since we can have several ways to convert a RGB to grayscale. It all
        depends of the accuracy we want and the targeted device. (HDTV, B&W Tv, analog TVs etc)
       
       
        For digital formats following CCIR 601 (i.e. most digital standard definition formats), luma is calculated with the formula
        Y' = 0.299 R' + 0.587 G' + 0.114 B'.
        Formats following ITU-R Recommendation BT.709 use the formula Y' = 0.2126 R' + 0.7152 G' + 0.0722 B'.
        Modern HDTV systems use the 709 coefficients, while transitional 1035i HDTV formats may use the SMPTE 240M coefficients
        (Y' = 0.212 R' + 0.701 G' + 0.087 B'). These coefficients correspond to the SMPTE RP 145 primaries (also known as "SMPTE C")
        in use at the time the standard was created.
        The change in the luma coefficients is to provide the "theoretically correct" coefficients that reflects the corresponding
        standard chromaticities ('colors') of the primaries red, green, and blue. However, there is some controversy regarding this decision.
        The difference in luma coefficients requires that component signals must be converted between Rec. 601 and Rec. 709 to provide accurate colors.
        In consumer equipment, the matrix required to perform this conversion may be omitted (to reduce cost), resulting in inaccurate color.
        As well, the Rec. 709 luma coefficients may not necessarily provide better performance. Because of the difference between luma and luminance,
        luma does not exactly represent the luminance in an image. As a result, errors in chroma can affect luminance.
        Luma alone does not perfectly represent luminance; accurate luminance requires both accurate luma and chroma.
        Hence, errors in chroma "bleed" into the luminance of an image.
        Due to the widespread usage of chroma subsampling, 'errors' in chroma typically occur when it is lowered in resolution/bandwidth.
        This lowered bandwidth, coupled with high frequency chroma components, can cause visible errors in luminance.
        An example of a high frequency chroma component would be the line between the green and magenta bars of the SMPTE color bars test pattern.
        Error in luminance can be seen as a dark band that occurs in this area.

        Other values of Luma and Chroma Video Components that can be used to calculate the gray values. (Only uses Y (Luminance) to convert to gray)
       
        Y', R'-Y', B'-Y' commonly used for analog encoding
        Format  1125/60/2:1, 720/60/1:1         525/59.94/2:1, 625/50/2:1, 1250/50/2:1
        Y'      0.2126 R'+0.7152 G'+0.0722 B'   0.299 R' + 0.587 G' + 0.114 B'
        R'-Y'   0.7874 R'–0.7152 G'–0.0722 B'   0.701 R' – 0.587 G' – 0.114 B'
        B'-Y'   –0.2126 R'–0.7152 G'+0.9278 B'  –0.299R' – 0.587 G' + 0.886 B'
       
        Y', P'b, P'r analog component
        Format      1125/60/2:1                 1920 x 1080 (SMPTE 274M)    525/59.94/2:1, 625/50/2:1, 1250/50/2:1
                    (SMPTE 240M)                1280 x 720 (SMPTE 296M)
        Y'          0.212R'+0.701G'+0.087B'     0.2126R'+0.7152G'+0.0722B'  0.299R' + 0.587G' + 0.114B'
        P'b         (B'-Y')/1.826               [0.5/(1–0.0722)](B'-Y')     0.564 (B'-Y')
        P'r         (R'-Y')/1.576               [0.5/(1–0.2126)](R'-Y')     0.713 (R'-Y')
       
        Y', C'b, C'r, scaled and offset for digital quantization

        Format      1920x1080 (SMPTE 274M)          525/59.94/2:1, 625/50/2:1, 1250/50/2:1
                    1280x720 (SMPTE 296M)
        Y'          0.2126 R'+0.7152 G'+0.0722 B'   0.299 R' + 0.587 G' + 0.114 B'
        C'b         0.5389 (B'-Y')+350 mV           0.564 (B'-Y') + 350 mV
        C'r         0.6350 (R'-Y')+350 mV           0.713 (R'-Y') + 350 mV


    ______________________________________________________________________________________________________________________________
    Requirements:
        None

    ______________________________________________________________________________________________________________________________
    See Also:
        Hue_2_RGB
        HLStoRGB
    ______________________________________________________________________________________________________________________________
    Bibliography:
    http://ethesis.nitrkl.ac.in/2876/1/kiran1thesis.pdf
    http://r0k.us/graphics/SIHwheel.html
    http://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.709-5-200204-I!!PDF-E.pdf
    http://www.itu.int/rec/R-REC-BT.709-5-200204-I/en
    http://portal.nersc.gov/svn/visit/branches/2.0RC/third_party/vtk/tags/vtk-5.0.0/Utilities/vtkmpeg2encode/readpic.c
    http://en.wikipedia.org/wiki/Luma_(video)
    http://www.scribd.com/doc/47921551/GuidetoDigitalVideoMeasurements
    http://en.wikipedia.org/wiki/HSL_and_HSV
    http://en.wikipedia.org/wiki/RGB_color_space
    http://mikro.naprvyraz.sk/docs/Coding/Hardware/COLORS.TXT
    http://www.mathworks.com/support/solutions/en/data/1-1ASCU/index.html?product=IP&solution=1-1ASCU
    http://gimp-savvy.com/BOOK/index.html?node54.html
    http://www.bobpowell.net/grayscale.htm
    http://www5.informatik.tu-muenchen.de/lehre/vorlesungen/graphik/info/csc/COL_33.htm
    http://en.wikipedia.org/wiki/YCbCr
    ______________________________________________________________________________________________________________________________   
    Author:
    Gustavo Trigueiros (aka: Beyond2000!)
    v1.0 June/2.011

;;



[GrayRedFactor: R$ 0.298912
GrayGreenFactor: R$ 0.586611
GrayBlueFactor: R$ 0.114478]

; see RGBtoYIQ

Proc RGBtoGray_Rec601:
    Arguments @Red, @Green, @Blue
    Local @Buffer
    uses esi
; G = R*GrayRedFactor+G*GrayGreenFactor+B*BFactor
    lea esi D@Buffer

    fild F@Red | fmul R$GrayRedFactor
    fild F@Green | fmul R$GrayGreenFactor
    faddp ST1 ST0
    fild F@Blue | fmul R$GrayBlueFactor
    faddp ST1 ST0
    fistp F$esi
    mov eax D$esi

EndP

[GrayRedFactor_Rec709: R$ 0.212671
GrayGreenFactor_Rec709: R$ 0.715160
GrayBlueFactor_Rec709: R$ 0.072169]

Proc RGBtoGray_Rec709:
    Arguments @Red, @Green, @Blue
    Local @Buffer
    uses esi

    lea esi D@Buffer

    fild F@Red | fmul R$GrayRedFactor_Rec709
    fild F@Green | fmul R$GrayGreenFactor_Rec709
    faddp ST1 ST0
    fild F@Blue | fmul R$GrayBlueFactor_Rec709
    faddp ST1 ST0
    fistp F$esi
    mov eax D$esi


EndP


[GrayRedFactor_SMPTE240: R$ 0.212
GrayGreenFactor_SMPTE240: R$ 0.701
GrayBlueFactor_SMPTE240: R$ 0.087]

Proc RGBtoGray_SMPTE240:
    Arguments @Red, @Green, @Blue
    Local @Buffer
    uses esi

    lea esi D@Buffer

    fild F@Red | fmul R$GrayRedFactor_SMPTE240
    fild F@Green | fmul R$GrayGreenFactor_SMPTE240
    faddp ST1 ST0
    fild F@Blue | fmul R$GrayBlueFactor_SMPTE240
    faddp ST1 ST0
    fistp F$esi
    mov eax D$esi


EndP

Proc RGBtoLuma:
    Arguments @Red, @Green, @Blue, @Luminance
    uses esi

    mov esi D@Luminance

    fild F@Red | fmul R$GrayRedFactor
    fild F@Green | fmul R$GrayGreenFactor
    faddp ST1 ST0
    fild F@Blue | fmul R$GrayBlueFactor
    faddp ST1 ST0
    fdiv R$Float255
    fstp R$esi

EndP
Title: Re: I would like a lesson
Post by: guga on December 24, 2015, 05:32:26 PM
If you need the proper tables for Lab, XYZ (using different white space observers) and the proper matrix table to convert to different RGB work spaces, let me know.  The tables are huge, but here are some of them from my RGBttoXYZ converter

[FloatXYZWorkSpacesMatrices:
FloatAdobe_RGB_1998_D65_Red_M1: R$ 0.5767309  FloatAdobe_RGB_1998_D65_Green_M2: R$ 0.185554     FloatAdobe_RGB_1998_D65_Blue_M3: R$ 0.1881852
FloatAdobe_RGB_1998_D65_Red_M4: R$ 0.2973769  FloatAdobe_RGB_1998_D65_Green_M5: R$ 0.6273491    FloatAdobe_RGB_1998_D65_Blue_M6: R$ 0.0752741
FloatAdobe_RGB_1998_D65_Red_M7: R$ 0.0270343  FloatAdobe_RGB_1998_D65_Green_M8: R$ 0.0706872    FloatAdobe_RGB_1998_D65_Blue_M9: R$ 0.9911085

FloatAppleRGB_D65_Red_M1: R$ 0.4497288        FloatAppleRGB_D65_Green_M2: R$ 0.3162486          FloatAppleRGB_D65_Blue_M3: R$ 0.1844926
FloatAppleRGB_D65_Red_M4: R$ 0.2446525        FloatAppleRGB_D65_Green_M5: R$ 0.6720283          FloatAppleRGB_D65_Blue_M6: R$ 0.0833192
FloatAppleRGB_D65_Red_M7: R$ 0.0251848        FloatAppleRGB_D65_Green_M8: R$ 0.1411824          FloatAppleRGB_D65_Blue_M9: R$ 0.9224628

FloatBest_RGB_D50_Red_M1: R$ 0.6326696        FloatBest_RGB_D50_Green_M2: R$ 0.2045558          FloatBest_RGB_D50_Blue_M3: R$ 0.1269946
FloatBest_RGB_D50_Red_M4: R$ 0.2284569        FloatBest_RGB_D50_Green_M5: R$ 0.7373523          FloatBest_RGB_D50_Blue_M6: R$ 0.0341908
FloatBest_RGB_D50_Red_M7: R$ 0                FloatBest_RGB_D50_Green_M8: R$ 0.0095142          FloatBest_RGB_D50_Blue_M9: R$ 0.8156958

FloatBeta_RGB_D50_Red_M1: R$ 0.6712537        FloatBeta_RGB_D50_Green_M2: R$ 0.1745834          FloatBeta_RGB_D50_Blue_M3: R$ 0.1183829
FloatBeta_RGB_D50_Red_M4: R$ 0.3032726        FloatBeta_RGB_D50_Green_M5: R$ 0.6637861          FloatBeta_RGB_D50_Blue_M6: R$ 0.0329413
FloatBeta_RGB_D50_Red_M7: R$ 0                FloatBeta_RGB_D50_Green_M8: R$ 0.040701           FloatBeta_RGB_D50_Blue_M9: R$ 0.784509

FloatBruce_RGB_D65_Red_M1: R$ 0.4674162       FloatBruce_RGB_D65_Green_M2: R$ 0.2944512         FloatBruce_RGB_D65_Blue_M3: R$ 0.1886026
FloatBruce_RGB_D65_Red_M4: R$ 0.2410115       FloatBruce_RGB_D65_Green_M5: R$ 0.6835475         FloatBruce_RGB_D65_Blue_M6: R$ 0.075441
FloatBruce_RGB_D65_Red_M7: R$ 0.0219101       FloatBruce_RGB_D65_Green_M8: R$ 0.0736128         FloatBruce_RGB_D65_Blue_M9: R$ 0.9933071

FloatCIE_RGB_E_Red_M1: R$ 0.488718            FloatCIE_RGB_E_Green_M2: R$ 0.3106803             FloatCIE_RGB_E_Blue_M3: R$ 0.2006017
FloatCIE_RGB_E_Red_M4: R$ 0.1762044           FloatCIE_RGB_E_Green_M5: R$ 0.8129847             FloatCIE_RGB_E_Blue_M6: R$ 0.0108109
FloatCIE_RGB_E_Red_M7: R$ 0                   FloatCIE_RGB_E_Green_M8: R$ 0.0102048             FloatCIE_RGB_E_Blue_M9: R$ 0.9897952

FloatColorMatch_RGB_D50_Red_M1: R$ 0.5093439  FloatColorMatch_RGB_D50_Green_M2: R$ 0.3209071    FloatColorMatch_RGB_D50_Blue_M3: R$ 0.1339691
FloatColorMatch_RGB_D50_Red_M4: R$ 0.274884   FloatColorMatch_RGB_D50_Green_M5: R$ 0.6581315    FloatColorMatch_RGB_D50_Blue_M6: R$ 0.0669845
FloatColorMatch_RGB_D50_Red_M7: R$ 0.0242545  FloatColorMatch_RGB_D50_Green_M8: R$ 0.1087821    FloatColorMatch_RGB_D50_Blue_M9: R$ 0.6921735

FloatDon_RGB_4_D50_Red_M1: R$ 0.6457711       FloatDon_RGB_4_D50_Green_M2: R$ 0.1933511         FloatDon_RGB_4_D50_Blue_M3: R$ 0.1250978
FloatDon_RGB_4_D50_Red_M4: R$ 0.2783496       FloatDon_RGB_4_D50_Green_M5: R$ 0.6879702         FloatDon_RGB_4_D50_Blue_M6: R$ 0.0336802
FloatDon_RGB_4_D50_Red_M7: R$ 0.0037113       FloatDon_RGB_4_D50_Green_M8: R$ 0.0179861         FloatDon_RGB_4_D50_Blue_M9: R$ 0.8035125

FloatECI_RGB_D50_Red_M1: R$ 0.6502043         FloatECI_RGB_D50_Green_M2: R$ 0.1780774           FloatECI_RGB_D50_Blue_M3: R$ 0.1359384
FloatECI_RGB_D50_Red_M4: R$ 0.3202499         FloatECI_RGB_D50_Green_M5: R$ 0.6020711           FloatECI_RGB_D50_Blue_M6: R$ 0.0776791
FloatECI_RGB_D50_Red_M7: R$ 0                 FloatECI_RGB_D50_Green_M8: R$ 0.067839            FloatECI_RGB_D50_Blue_M9: R$ 0.757371

FloatEkta_Space_PS5_D50_Red_M1: R$ 0.5938914  FloatEkta_Space_PS5_D50_Green_M2: R$ 0.2729801    FloatEkta_Space_PS5_D50_Blue_M3: R$ 0.0973485
FloatEkta_Space_PS5_D50_Red_M4: R$ 0.2606286  FloatEkta_Space_PS5_D50_Green_M5: R$ 0.7349465    FloatEkta_Space_PS5_D50_Blue_M6: R$ 0.0044249
FloatEkta_Space_PS5_D50_Red_M7: R$ 0          FloatEkta_Space_PS5_D50_Green_M8: R$ 0.0419969    FloatEkta_Space_PS5_D50_Blue_M9: R$ 0.7832131

FloatNTSC_RGB_C_Red_M1: R$ 0.6068909          FloatNTSC_RGB_C_Green_M2: R$ 0.1735011            FloatNTSC_RGB_C_Blue_M3: R$ 0.200348
FloatNTSC_RGB_C_Red_M4: R$ 0.2989164          FloatNTSC_RGB_C_Green_M5: R$ 0.586599             FloatNTSC_RGB_C_Blue_M6: R$ 0.1144845
FloatNTSC_RGB_C_Red_M7: R$ 0                  FloatNTSC_RGB_C_Green_M8: R$ 0.0660957            FloatNTSC_RGB_C_Blue_M9: R$ 1.1162243

FloatPAL_SECAM_RGB_D65_Red_M1: R$ 0.430619    FloatPAL_SECAM_RGB_D65_Green_M2: R$ 0.3415419     FloatPAL_SECAM_RGB_D65_Blue_M3: R$ 0.1783091
FloatPAL_SECAM_RGB_D65_Red_M4: R$ 0.2220379   FloatPAL_SECAM_RGB_D65_Green_M5: R$ 0.7066384     FloatPAL_SECAM_RGB_D65_Blue_M6: R$ 0.0713236
FloatPAL_SECAM_RGB_D65_Red_M7: R$ 0.0201853   FloatPAL_SECAM_RGB_D65_Green_M8: R$ 0.1295504     FloatPAL_SECAM_RGB_D65_Blue_M9: R$ 0.9390944

FloatProPhoto_RGB_D50_Red_M1: R$ 0.7976749    FloatProPhoto_RGB_D50_Green_M2: R$ 0.1351917      FloatProPhoto_RGB_D50_Blue_M3: R$ 0.0313534
FloatProPhoto_RGB_D50_Red_M4: R$ 0.2880402    FloatProPhoto_RGB_D50_Green_M5: R$ 0.7118741      FloatProPhoto_RGB_D50_Blue_M6: R$ 0.0000857
FloatProPhoto_RGB_D50_Red_M7: R$ 0            FloatProPhoto_RGB_D50_Green_M8: R$ 0              FloatProPhoto_RGB_D50_Blue_M9: R$ 0.82521

FloatSMPTE_C_RGB_D65_Red_M1: R$ 0.3935891     FloatSMPTE_C_RGB_D65_Green_M2: R$ 0.3652497       FloatSMPTE_C_RGB_D65_Blue_M3: R$ 0.1916313
FloatSMPTE_C_RGB_D65_Red_M4: R$ 0.2124132     FloatSMPTE_C_RGB_D65_Green_M5: R$ 0.7010437       FloatSMPTE_C_RGB_D65_Blue_M6: R$ 0.0865432
FloatSMPTE_C_RGB_D65_Red_M7: R$ 0.0187423     FloatSMPTE_C_RGB_D65_Green_M8: R$ 0.1119313       FloatSMPTE_C_RGB_D65_Blue_M9: R$ 0.9581563

FloatsRGB_D65_Red_M1: R$ 0.4124564            FloatsRGB_D65_Green_M2: R$ 0.3575761              FloatsRGB_D65_Blue_M3: R$ 0.1804375
FloatsRGB_D65_Red_M4: R$ 0.2126729            FloatsRGB_D65_Green_M5: R$ 0.7151522              FloatsRGB_D65_Blue_M6: R$ 0.0721750
FloatsRGB_D65_Red_M7: R$ 0.0193339            FloatsRGB_D65_Green_M8: R$ 0.1191920              FloatsRGB_D65_Blue_M9: R$ 0.9503041

FloatWide_Gamut_RGB_D50_Red_M1: R$ 0.7161046  FloatWide_Gamut_RGB_D50_Green_M2: R$ 0.1009296    FloatWide_Gamut_RGB_D50_Blue_M3: R$ 0.1471858
FloatWide_Gamut_RGB_D50_Red_M4: R$ 0.2581874  FloatWide_Gamut_RGB_D50_Green_M5: R$ 0.7249378    FloatWide_Gamut_RGB_D50_Blue_M6: R$ 0.0168748
FloatWide_Gamut_RGB_D50_Red_M7: R$ 0          FloatWide_Gamut_RGB_D50_Green_M8: R$ 0.0517813    FloatWide_Gamut_RGB_D50_Blue_M9: R$ 0.7734287


FloatAdobe_RGB_1998_D50_M1: R$ 0.6097559      FloatAdobe_RGB_1998_D50_M2: R$ 0.2052401          FloatAdobe_RGB_1998_D50_M3: R$ 0.1492240
FloatAdobe_RGB_1998_D50_M4: R$ 0.3111242      FloatAdobe_RGB_1998_D50_M5: R$ 0.6256560          FloatAdobe_RGB_1998_D50_M6: R$ 0.0632197
FloatAdobe_RGB_1998_D50_M7: R$ 0.0194811      FloatAdobe_RGB_1998_D50_M8: R$ 0.0608902          FloatAdobe_RGB_1998_D50_M9: R$ 0.7448387

FloatAppleRGB_D50_M1: R$ 0.4755678            FloatAppleRGB_D50_M2: R$ 0.3396722                FloatAppleRGB_D50_M3: R$ 0.1489800
FloatAppleRGB_D50_M4: R$ 0.2551812            FloatAppleRGB_D50_M5: R$ 0.6725693                FloatAppleRGB_D50_M6: R$ 0.0722496
FloatAppleRGB_D50_M7: R$ 0.0184697            FloatAppleRGB_D50_M8: R$ 0.1133771                FloatAppleRGB_D50_M9: R$ 0.6933632

FloatBruce_RGB_D50_M1: R$ 0.4941816           FloatBruce_RGB_D50_M2: R$ 0.3204834               FloatBruce_RGB_D50_M3: R$ 0.1495550
FloatBruce_RGB_D50_M4: R$ 0.2521531           FloatBruce_RGB_D50_M5: R$ 0.6844869               FloatBruce_RGB_D50_M6: R$ 0.0633600
FloatBruce_RGB_D50_M7: R$ 0.0157886           FloatBruce_RGB_D50_M8: R$ 0.0629304               FloatBruce_RGB_D50_M9: R$ 0.7464909

FloatCIE_RGB_D50_M1: R$ 0.4868870             FloatCIE_RGB_D50_M2: R$ 0.3062984                 FloatCIE_RGB_D50_M3: R$ 0.1710347
FloatCIE_RGB_D50_M4: R$ 0.1746583             FloatCIE_RGB_D50_M5: R$ 0.8247541                 FloatCIE_RGB_D50_M6: R$ 0.0005877
FloatCIE_RGB_D50_M7: R$ -0.0012563            FloatCIE_RGB_D50_M8: R$ 0.0169832                 FloatCIE_RGB_D50_M9: R$ 0.8094831

FloatNTSC_RGB_D50_M1: R$ 0.6343706            FloatNTSC_RGB_D50_M2: R$ 0.1852204                FloatNTSC_RGB_D50_M3: R$ 0.1446290
FloatNTSC_RGB_D50_M4: R$ 0.3109496            FloatNTSC_RGB_D50_M5: R$ 0.5915984                FloatNTSC_RGB_D50_M6: R$ 0.0974520
FloatNTSC_RGB_D50_M7: R$ -0.0011817           FloatNTSC_RGB_D50_M8: R$ 0.0555518                FloatNTSC_RGB_D50_M9: R$ 0.7708399

FloatPAL_SECAM_RGB_D50_M1: R$ 0.4552773       FloatPAL_SECAM_RGB_D50_M2: R$ 0.3675500           FloatPAL_SECAM_RGB_D50_M3: R$ 0.1413926
FloatPAL_SECAM_RGB_D50_M4: R$ 0.2323025       FloatPAL_SECAM_RGB_D50_M5: R$ 0.7077956           FloatPAL_SECAM_RGB_D50_M6: R$ 0.0599019
FloatPAL_SECAM_RGB_D50_M7: R$ 0.0145457       FloatPAL_SECAM_RGB_D50_M8: R$ 0.1049154           FloatPAL_SECAM_RGB_D50_M9: R$ 0.7057489

FloatSMPTE_C_RGB_D50_M1: R$ 0.4163290         FloatSMPTE_C_RGB_D50_M2: R$ 0.3931464             FloatSMPTE_C_RGB_D50_M3: R$ 0.1547446
FloatSMPTE_C_RGB_D50_M4: R$ 0.2216999         FloatSMPTE_C_RGB_D50_M5: R$ 0.7032549             FloatSMPTE_C_RGB_D50_M6: R$ 0.0750452
FloatSMPTE_C_RGB_D50_M7: R$ 0.0136576         FloatSMPTE_C_RGB_D50_M8: R$ 0.0913604             FloatSMPTE_C_RGB_D50_M9: R$ 0.7201920

FloatsRGB_D50_M1: R$ 0.4360747                FloatsRGB_D50_M2: R$ 0.3850649                    FloatsRGB_D50_M3: R$ 0.1430804
FloatsRGB_D50_M4: R$ 0.2225045                FloatsRGB_D50_M5: R$ 0.7168786                    FloatsRGB_D50_M6: R$ 0.0606169
FloatsRGB_D50_M7: R$ 0.0139322                FloatsRGB_D50_M8: R$ 0.0971045                    FloatsRGB_D50_M9: R$ 0.7141733

FloatsRGB_D65_Red_HDTV_M1: R$ 0.4124564       FloatsRGB_D65_Green_HDTV_M2: R$ 0.3575761         FloatsRGB_D65_Blue_HDTV_M3: R$ 0.1804375
FloatsRGB_D65_Red_HDTV_M4: R$ 0.2126729       FloatsRGB_D65_Green_HDTV_M5: R$ 0.7151522         FloatsRGB_D65_Blue_HDTV_M6: R$ 0.0721750
FloatsRGB_D65_Red_HDTV_M7: R$ 0.0193339       FloatsRGB_D65_Green_HDTV_M8: R$ 0.1191920         FloatsRGB_D65_Blue_HDTV_M9: R$ 0.9503041]
Title: Re: I would like a lesson
Post by: Grincheux on December 24, 2015, 06:35:08 PM
Ok, I will use them.
I have three projects at the same time and only one head.
Title: Re: I would like a lesson
Post by: FORTRANS on December 25, 2015, 12:06:04 AM
Hi,

   Here it is.  The original image format was column ordered 750 x 480.
One byte per pixel.  Pixels surrounding the central pixel are labeled
A0 through A7, point of interest is f(i,k), and the calculated Sobel
function is G(i,k).  The JL (jump less) should probably be JBE (jump
below or equal) but either work in practice.


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SOBELDAT DW     (?)             ; Value from Sobel algorithm.

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
COMMENT\
See Digital Image Processing by Pratt 1st ed., page 487.

  G(j,k) = SQRT( X^2 + Y^2 ), where X = (A2 + 2A3 + A4) - (A0 + 2A7 + A6)
                                    Y = (A0 + 2A1 + A2) - (A6 + 2A5 + A4)
  A0   A1   A2
  A7  f(ik) A3
  A6   A5   A4
\
SOBEL:
;@      FINIT           ; Initialize 8087 (Needs to be done somewhere before calling Sobel.)
        XOR     AX,AX   ; X1
        XOR     BX,BX   ; X2
        XOR     CX,CX   ; Y1
        XOR     DX,DX   ; Y2

        ADD     BL,ES:[DI-479]  ; A0
        ADC     BH,0
        ADD     CL,ES:[DI-479]  ; A0
        ADC     CH,0
        ADD     BL,ES:[DI-480]  ; A7
        ADC     BH,0
        ADD     BL,ES:[DI-480]  ; A7
        ADC     BH,0
        ADD     BL,ES:[DI-481]  ; A6
        ADC     BH,0
        ADD     DL,ES:[DI-481]  ; A6
        ADC     DH,0
        ADD     CL,ES:[DI-1]    ; A1
        ADC     CH,0
        ADD     CL,ES:[DI-1]    ; A1
        ADC     CH,0
        ADD     DL,ES:[DI+1]    ; A5
        ADC     DH,0
        ADD     DL,ES:[DI+1]    ; A5
        ADC     DH,0
        ADD     AL,ES:[DI+479]  ; A2
        ADC     AH,0
        ADD     CL,ES:[DI+479]  ; A2
        ADC     CH,0
        ADD     AL,ES:[DI+480]  ; A3
        ADC     AH,0
        ADD     AL,ES:[DI+480]  ; A3
        ADC     AH,0
        ADD     AL,ES:[DI+481]  ; A4
        ADC     AH,0
        ADD     DL,ES:[DI+481]  ; A4
        ADC     DH,0

        SUB     AX,BX    ; Make X
        SUB     CX,DX    ; Make Y
        MOV     SOBELDAT,AX
        FILD    SOBELDAT ; load X into 8087
        FIMUL   SOBELDAT

        MOV     SOBELDAT,CX
        FILD    SOBELDAT ; load Y into 8087
        FIMUL   SOBELDAT

        FADD
        FSQRT
        FISTP   SOBELDAT

        XOR     AX,AX
        ADD     AX,SOBELDAT     ; Set Flags

        JNS     POSITIVE
        MOV     AX,0
POSITIVE:
        CMP     AX,255
        JL      NoClamp
        MOV     AX,255
NoClamp:

        RET

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


HTH,

Steve N.
Title: Re: I would like a lesson
Post by: Grincheux on December 25, 2015, 07:03:24 AM
You are quicker than I.
:t

Thanks. I take all
Title: Re: I would like a lesson
Post by: Farabi on January 02, 2016, 01:52:28 PM
As far as I can understood, what we called art is any infinity number of processing power, which mean, the data we processed. For example, color had about 4 bilions color, if you see gold photograph, you can see that that gold color was more than 4 billions of posibility on a single picture. Can you get it? You can use photoshop and see the each pixel color gradation. It used to be called shading.

So do mountain and songs. You heard about 128kilobits per seconds, about 32 frames each, about 4kilobits per frame about 500 frequency per frame, ranged from 20khz into high pitch frequency, I forget about the details, its been a more than decade ago I researched into this, you can ask Microsoft or Google about this subject, under the "Speech Recognition" rules order. I mean, the algorithm programming law order.