Dosen : Prof.Dr. Suhartono M.Kom

Lembaga : UIN Maliki Malang

Selamat Malam, pada kesempatan kali ini saya akan memberikan sebuah cara untuk menganalisis suatu gambar dalam bentuk matrix, caranya bisa dilihat di bawah ini

  1. Install Package Pertama kita harus menginstall package EBImage terlebih dahulu
library(EBImage)
  1. Memanggil Gambar Code dibawah ini bisa diinputkan untuk pemanggilan gambar. Agar gambar terbaca, maka panggil lokasi dari gambar tersebut berada, maka outputnya akan muncul gambar yang kita inginkan.
Image <- readImage("C://Users/LENOVO/Documents/ENGGAR/WALLPAPER/megumin.jpg")
print(Image)
## Image 
##   colorMode    : Color 
##   storage.mode : double 
##   dim          : 2000 1414 3 
##   frames.total : 3 
##   frames.render: 1 
## 
## imageData(object)[1:5,1:6,1]
##           [,1]      [,2]      [,3]      [,4]      [,5]      [,6]
## [1,] 0.2078431 0.2352941 0.2392157 0.2235294 0.2352941 0.2313725
## [2,] 0.2274510 0.2588235 0.2588235 0.2431373 0.2549020 0.2509804
## [3,] 0.2392157 0.2705882 0.2666667 0.2549020 0.2627451 0.2588235
## [4,] 0.2274510 0.2588235 0.2549020 0.2431373 0.2509804 0.2509804
## [5,] 0.2235294 0.2549020 0.2509804 0.2392157 0.2549020 0.2549020
  1. Menampilkan Histogram Gambar Tersebut kita bisa menampilkan histogram dari gambar dengan cara memasukkan kode dibawah ini
hist(Image)

  1. Atur Brightness
Image1 <- Image + 0.2
Image2 <- Image - 0.2
par(mfrow= c(1,2))
plot(Image1)
plot(Image2)

  1. Menambahkan Kontras
Image3 <- Image * 0.5
Image4 <- Image * 2
par(mfrow = c(1,2))
plot(Image3)
plot(Image4)

  1. Koreksi Gamma
Image5 <- Image ^ 2
Image6 <- Image ^ 0.7
par(mfrow= c(1,2))
plot(Image5)
plot(Image6)

  1. Cropping
display(Image[189:700, 95:300,])

  1. Transformasi Spasial
Imagetr <- translate(rotate(Image, 45), c(50, 0))
display(Imagetr)

  1. Manajemen Warna
colorMode(Image) <- Grayscale
display(Image)
## Only the first frame of the image stack is displayed.
## To display all frames use 'all = TRUE'.

  1. Filter
fLow <- makeBrush(21, shape= 'disc', step=FALSE)^2
fLow <- fLow/sum(fLow)
Image.fLow <- filter2(Image, fLow)
display(Image.fLow)
## Only the first frame of the image stack is displayed.
## To display all frames use 'all = TRUE'.

  1. High-pass Filter
fHigh <- matrix(1, nc = 3, nr = 3)
fHigh[2, 2] <- -8
Image.fHigh <- filter2(Image, fHigh)
display(Image.fHigh)
## Only the first frame of the image stack is displayed.
## To display all frames use 'all = TRUE'.

Daftar Pustaka :

https://thinkstudioo.blogspot.com/2018/03/analisis-image-menggunakan-ebimage-di-r.html

https://thinkstudioo.blogspot.com/2018/03/analisis-image-menggunakan-ebimage-di-r_6.html