Hello, welcome SMALL Basic programmer.
In this tutorial we will learn how to make histogram program; that is program that count how many pixel a pixel color are in an image.
So the program like this:
TextWindow.WriteLine("1. Enter the file path of the image: ")
ifp = TextWindow.Read()
TextWindow.WriteLine("2. Enter the width information image: ")
wii = TextWindow.Read()
TextWindow.WriteLine("3. Enter the height information image: ")
hii = TextWindow.Read()
'1. Load or draw the image
GraphicsWindow.DrawImage(ifp,0,0)
'2. Get all the pixel's color information from pixel index 0,0 to 200,200
For i = 0 To hii
For j = 0 To wii
'get all the pixel's color information
pc = GraphicsWindow.GetPixel(i,j)
If i = 0 And j = 0 Then
col_arr[0][0] = pc
col_arr[0][1] = 1
Goto quit
EndIf
'Checking with col_arr array (col_arr stands for color array)
For k = 0 To array.GetItemCount(col_arr) - 1
If pc = col_arr[k][0] Then
col_arr[k][1] = col_arr[k][1] + 1
max = 1 'to trace the length of the row of the col_array
Goto quitloopk
Else
If k = Array.GetItemCount(col_arr) - 1 Then
col_arr[max][0] = pc
col_array[max][1] = 1
max = max + 1
EndIf
EndIf
quit:
EndFor
quitloopk:
EndFor
EndFor
TextWindow.WriteLine("No."+"Color"+"Number of pixels")
For i = 0 To Array.GetItemCount(col_arr) - 1
TextWindow.WriteLine(i +","+col_arr[i][0]+":"+col_arr[i][1]+" Pixels")
EndFor
In this tutorial we will learn how to make histogram program; that is program that count how many pixel a pixel color are in an image.
So the program like this:
TextWindow.WriteLine("1. Enter the file path of the image: ")
ifp = TextWindow.Read()
TextWindow.WriteLine("2. Enter the width information image: ")
wii = TextWindow.Read()
TextWindow.WriteLine("3. Enter the height information image: ")
hii = TextWindow.Read()
'1. Load or draw the image
GraphicsWindow.DrawImage(ifp,0,0)
'2. Get all the pixel's color information from pixel index 0,0 to 200,200
For i = 0 To hii
For j = 0 To wii
'get all the pixel's color information
pc = GraphicsWindow.GetPixel(i,j)
If i = 0 And j = 0 Then
col_arr[0][0] = pc
col_arr[0][1] = 1
Goto quit
EndIf
'Checking with col_arr array (col_arr stands for color array)
For k = 0 To array.GetItemCount(col_arr) - 1
If pc = col_arr[k][0] Then
col_arr[k][1] = col_arr[k][1] + 1
max = 1 'to trace the length of the row of the col_array
Goto quitloopk
Else
If k = Array.GetItemCount(col_arr) - 1 Then
col_arr[max][0] = pc
col_array[max][1] = 1
max = max + 1
EndIf
EndIf
quit:
EndFor
quitloopk:
EndFor
EndFor
TextWindow.WriteLine("No."+"Color"+"Number of pixels")
For i = 0 To Array.GetItemCount(col_arr) - 1
TextWindow.WriteLine(i +","+col_arr[i][0]+":"+col_arr[i][1]+" Pixels")
EndFor
Tidak ada komentar:
Posting Komentar