SlideShare a Scribd company logo
IMAGE PROCESSING IN R
SARAVANAKUMAR SEKAR
14 May 2018
library(EBImage)
#image1=readImage("~//pp//pic1.jpg")
#image2=readImage("~//pp//pic2.jpg")
#print(image1)
#display(image1)
image3=readImage("http://all4desktop.com/data_images/1920%20x%201080/4166784-
ms-dhoni-HD.jpg")
Inference
Here I get image from internet using link of that image
print(image3)
## Image
## colorMode : Color
## storage.mode : double
## dim : 1920 1080 3
## frames.total : 3
## frames.render: 1
##
## imageData(object)[1:5,1:6,1]
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 0.4235294 0.4078431 0.4274510 0.4235294 0.4235294 0.4392157
## [2,] 0.4196078 0.4039216 0.4078431 0.4156863 0.4274510 0.4431373
## [3,] 0.4156863 0.4078431 0.3960784 0.4039216 0.4156863 0.4274510
## [4,] 0.4117647 0.4156863 0.4000000 0.4000000 0.4000000 0.4000000
## [5,] 0.4000000 0.4156863 0.4039216 0.4078431 0.4078431 0.4000000
Inference
In this print statement , it tell about overview of the image
In this image colorMode is denoted the it color or not ?
And it tell dim size ,frame.total,frames.render and image clarity weight
display(image3)
Inference
Using display for view the image
image4=readImage("http://www.olympicsupdate.com/wp-content/uploads/2016/02/MS
-Dhoni-wallpapers.jpg")
print(image4)
## Image
## colorMode : Color
## storage.mode : double
## dim : 1920 1080 3
## frames.total : 3
## frames.render: 1
##
## imageData(object)[1:5,1:6,1]
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 0.2705882 0.2666667 0.2666667 0.2627451 0.2627451 0.2666667
## [2,] 0.2745098 0.2745098 0.2705882 0.2666667 0.2666667 0.2666667
## [3,] 0.2823529 0.2784314 0.2745098 0.2705882 0.2705882 0.2705882
## [4,] 0.2784314 0.2784314 0.2745098 0.2705882 0.2705882 0.2705882
## [5,] 0.2705882 0.2705882 0.2705882 0.2705882 0.2705882 0.2705882
display(image4)
#histogram for image
hist(image3)
Inference
In this chart based we can tell about the intensity range and pixels of the image .
If any changes will occur in manipulating this chart intensity will change based on the
manipulating weight.
hist(image4)
#manipulating brightness
b1=image4+0.2
Inference
In this image I just increase the brightness 0.2 for image 4
print(b1)
## Image
## colorMode : Color
## storage.mode : double
## dim : 1920 1080 3
## frames.total : 3
## frames.render: 1
##
## imageData(object)[1:5,1:6,1]
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 0.4705882 0.4666667 0.4666667 0.4627451 0.4627451 0.4666667
## [2,] 0.4745098 0.4745098 0.4705882 0.4666667 0.4666667 0.4666667
## [3,] 0.4823529 0.4784314 0.4745098 0.4705882 0.4705882 0.4705882
## [4,] 0.4784314 0.4784314 0.4745098 0.4705882 0.4705882 0.4705882
## [5,] 0.4705882 0.4705882 0.4705882 0.4705882 0.4705882 0.4705882
Inference
Using print statement we can see the weight difference before weight is 0.27 but now 0.47i
n the category of brightness
display(b1)
b2=image4-0.4
print(b2)
## Image
## colorMode : Color
## storage.mode : double
## dim : 1920 1080 3
## frames.total : 3
## frames.render: 1
##
## imageData(object)[1:5,1:6,1]
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] -0.1294118 -0.1333333 -0.1333333 -0.1372549 -0.1372549 -0.1333333
## [2,] -0.1254902 -0.1254902 -0.1294118 -0.1333333 -0.1333333 -0.1333333
## [3,] -0.1176471 -0.1215686 -0.1254902 -0.1294118 -0.1294118 -0.1294118
## [4,] -0.1215686 -0.1215686 -0.1254902 -0.1294118 -0.1294118 -0.1294118
## [5,] -0.1294118 -0.1294118 -0.1294118 -0.1294118 -0.1294118 -0.1294118
Inference
Here I reduced the brightness 0.4 now we can see the difference of the image in print state
ment.
display(b2)
hist(b2)
#manipulating contrast
c1=image4*0.3
Inference
Here I increase the image contrast0.3
display(c1)
c2=image4*1
Inference
last image contrast is very low so again I increase the contrast from 0.3 to 1 .using * symbol
we can modify the image contrast
display(c2)
#gamma corrections
g1=image4>0.3
display(g1)
g2=image4>0.6
display(g2)
g3=image4<0.5
display(g3)
Inference
Gamma is used for manipulate the darkness of the picture. Here, I just increase the darknes
s from 0.3 to 0.6 using >and < symbols
#color
colorMode(image4)=Grayscale
print(image4)
## Image
## colorMode : Grayscale
## storage.mode : double
## dim : 1920 1080 3
## frames.total : 3
## frames.render: 3
##
## imageData(object)[1:5,1:6,1]
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 0.2705882 0.2666667 0.2666667 0.2627451 0.2627451 0.2666667
## [2,] 0.2745098 0.2745098 0.2705882 0.2666667 0.2666667 0.2666667
## [3,] 0.2823529 0.2784314 0.2745098 0.2705882 0.2705882 0.2705882
## [4,] 0.2784314 0.2784314 0.2745098 0.2705882 0.2705882 0.2705882
## [5,] 0.2705882 0.2705882 0.2705882 0.2705882 0.2705882 0.2705882
#to return to color
colorMode(image4)=Color
Inference
ColorMode is use for manipulate color. Here I changed the colorMode from color to graysca
le and again I changed to color
#cropping
k=image4[60:860,360:960,]
display(k)
Inference
Cropping is again important manipulating operating in image processing . Here,I just crop
in this range of 60:860,360:960.
#new image file
writeImage(k,"MS.jpg")
Inference
In EBimage have write operation for save your all updates pictures in your local machine u
sing writeImage.
#flip,flop,rotate resize
l=flip(image4)
display(l)
m=flop(image4)
display(m)
r=rotate(image4,45)
display(r)
o=resize(image4,360)
display(o)
Inference
Using Flip,flop,rotate and resize commands we can flip and flop the image ,rotate the image
, and resize the image, which size you want?
#low-pass filter
low=makeBrush(21,shape = "disc",step = FALSE)
low=low/sum(low)
image.low=filter2(image4,low)
display(image.low)
low=makeBrush(81,shape = "disc",step = FALSE)
low=low/sum(low)
image.low=filter2(image3,low)
display(image.low)
#high-pass filter
high=matrix(1,nc=3,nr=3)
high[2,2]=-5
image.high=filter2(image4,high)
display(image.high)
Inference
Low-pass filter and high-pass filter is used for just blur the image whatever you want?
# combine
c=combine(image3,image4)
display(c)
## Only the first frame of the image stack is displayed.
## To display all frames use 'all = TRUE'.
Inference
We can merge the image one by one using combine command. Here I combine image3 and i
mage4
#put two image into one
i1=image3+image4
display(i1)
hist(i1)
i2=image3/3+image4
display(i2)
hist(i2)
Inference
Here I put two image into one image
If you want second image is more thickness compare with first image just increase the first
image thickness using / symbol

More Related Content

PDF
第2回 基本演算,データ型の基礎,ベクトルの操作方法(解答付き)
PDF
第4回 データフレームの基本操作 その2(解答付き)
PDF
1024+ Seconds of JS Wizardry - JSConf.eu 2013
PDF
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)
PPTX
Can Guinness help you estimate?
PDF
Dipôles linéaires, régime transitoire
PDF
مطوية الدعاء من الكتاب والسنة
KEY
A Type Driven Approach to Functional Design
第2回 基本演算,データ型の基礎,ベクトルの操作方法(解答付き)
第4回 データフレームの基本操作 その2(解答付き)
1024+ Seconds of JS Wizardry - JSConf.eu 2013
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)
Can Guinness help you estimate?
Dipôles linéaires, régime transitoire
مطوية الدعاء من الكتاب والسنة
A Type Driven Approach to Functional Design

Similar to Image Processing in R (20)

PDF
Image processing
PDF
Data Science - Part XVII - Deep Learning & Image Processing
PPTX
Introduction to Image Processing with MATLAB
PPT
Matlab
DOC
Simple Matlab tutorial using matlab inbuilt commands
PPT
Dital Image Processing (Lab 2+3+4)
PPTX
ImageProcessingWithMatlab(HasithaEdiriweera)
PPTX
Images in matlab
PPTX
EBImage - Short Overview
PDF
Image processing basics using matlab
PPTX
project_final_seminar
PPTX
Working with images in matlab graphics
DOCX
PDF
PPT
Introduction to Digital Image Processing
PDF
IRJET- 3D Vision System using Calibrated Stereo Camera
PPTX
Introduction_____to______ OpenCV___.pptx
PPTX
Image Processing Using MATLAB
PPTX
Image processing in MATLAB
DOCX
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
Image processing
Data Science - Part XVII - Deep Learning & Image Processing
Introduction to Image Processing with MATLAB
Matlab
Simple Matlab tutorial using matlab inbuilt commands
Dital Image Processing (Lab 2+3+4)
ImageProcessingWithMatlab(HasithaEdiriweera)
Images in matlab
EBImage - Short Overview
Image processing basics using matlab
project_final_seminar
Working with images in matlab graphics
Introduction to Digital Image Processing
IRJET- 3D Vision System using Calibrated Stereo Camera
Introduction_____to______ OpenCV___.pptx
Image Processing Using MATLAB
Image processing in MATLAB
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
Ad

Recently uploaded (20)

PPTX
Qualitative Qantitative and Mixed Methods.pptx
PDF
Introduction to Data Science and Data Analysis
PPTX
Database Infoormation System (DBIS).pptx
PPTX
SAP 2 completion done . PRESENTATION.pptx
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PDF
Optimise Shopper Experiences with a Strong Data Estate.pdf
PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PPTX
Managing Community Partner Relationships
PPTX
STERILIZATION AND DISINFECTION-1.ppthhhbx
PPTX
Supervised vs unsupervised machine learning algorithms
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PDF
Data Engineering Interview Questions & Answers Cloud Data Stacks (AWS, Azure,...
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Qualitative Qantitative and Mixed Methods.pptx
Introduction to Data Science and Data Analysis
Database Infoormation System (DBIS).pptx
SAP 2 completion done . PRESENTATION.pptx
Data_Analytics_and_PowerBI_Presentation.pptx
Optimise Shopper Experiences with a Strong Data Estate.pdf
Reliability_Chapter_ presentation 1221.5784
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
Introduction-to-Cloud-ComputingFinal.pptx
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
Managing Community Partner Relationships
STERILIZATION AND DISINFECTION-1.ppthhhbx
Supervised vs unsupervised machine learning algorithms
Miokarditis (Inflamasi pada Otot Jantung)
climate analysis of Dhaka ,Banglades.pptx
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
Data Engineering Interview Questions & Answers Cloud Data Stacks (AWS, Azure,...
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Ad

Image Processing in R

  • 1. IMAGE PROCESSING IN R SARAVANAKUMAR SEKAR 14 May 2018 library(EBImage) #image1=readImage("~//pp//pic1.jpg") #image2=readImage("~//pp//pic2.jpg") #print(image1) #display(image1) image3=readImage("http://all4desktop.com/data_images/1920%20x%201080/4166784- ms-dhoni-HD.jpg") Inference Here I get image from internet using link of that image print(image3) ## Image ## colorMode : Color ## storage.mode : double ## dim : 1920 1080 3 ## frames.total : 3 ## frames.render: 1 ## ## imageData(object)[1:5,1:6,1] ## [,1] [,2] [,3] [,4] [,5] [,6] ## [1,] 0.4235294 0.4078431 0.4274510 0.4235294 0.4235294 0.4392157 ## [2,] 0.4196078 0.4039216 0.4078431 0.4156863 0.4274510 0.4431373 ## [3,] 0.4156863 0.4078431 0.3960784 0.4039216 0.4156863 0.4274510 ## [4,] 0.4117647 0.4156863 0.4000000 0.4000000 0.4000000 0.4000000 ## [5,] 0.4000000 0.4156863 0.4039216 0.4078431 0.4078431 0.4000000 Inference In this print statement , it tell about overview of the image In this image colorMode is denoted the it color or not ? And it tell dim size ,frame.total,frames.render and image clarity weight
  • 2. display(image3) Inference Using display for view the image image4=readImage("http://www.olympicsupdate.com/wp-content/uploads/2016/02/MS -Dhoni-wallpapers.jpg") print(image4) ## Image ## colorMode : Color ## storage.mode : double ## dim : 1920 1080 3 ## frames.total : 3 ## frames.render: 1 ## ## imageData(object)[1:5,1:6,1] ## [,1] [,2] [,3] [,4] [,5] [,6] ## [1,] 0.2705882 0.2666667 0.2666667 0.2627451 0.2627451 0.2666667 ## [2,] 0.2745098 0.2745098 0.2705882 0.2666667 0.2666667 0.2666667 ## [3,] 0.2823529 0.2784314 0.2745098 0.2705882 0.2705882 0.2705882
  • 3. ## [4,] 0.2784314 0.2784314 0.2745098 0.2705882 0.2705882 0.2705882 ## [5,] 0.2705882 0.2705882 0.2705882 0.2705882 0.2705882 0.2705882 display(image4) #histogram for image hist(image3)
  • 4. Inference In this chart based we can tell about the intensity range and pixels of the image . If any changes will occur in manipulating this chart intensity will change based on the manipulating weight. hist(image4)
  • 5. #manipulating brightness b1=image4+0.2 Inference In this image I just increase the brightness 0.2 for image 4 print(b1) ## Image ## colorMode : Color ## storage.mode : double ## dim : 1920 1080 3 ## frames.total : 3 ## frames.render: 1 ## ## imageData(object)[1:5,1:6,1] ## [,1] [,2] [,3] [,4] [,5] [,6] ## [1,] 0.4705882 0.4666667 0.4666667 0.4627451 0.4627451 0.4666667 ## [2,] 0.4745098 0.4745098 0.4705882 0.4666667 0.4666667 0.4666667 ## [3,] 0.4823529 0.4784314 0.4745098 0.4705882 0.4705882 0.4705882 ## [4,] 0.4784314 0.4784314 0.4745098 0.4705882 0.4705882 0.4705882 ## [5,] 0.4705882 0.4705882 0.4705882 0.4705882 0.4705882 0.4705882 Inference
  • 6. Using print statement we can see the weight difference before weight is 0.27 but now 0.47i n the category of brightness display(b1) b2=image4-0.4 print(b2) ## Image ## colorMode : Color ## storage.mode : double ## dim : 1920 1080 3 ## frames.total : 3 ## frames.render: 1 ## ## imageData(object)[1:5,1:6,1] ## [,1] [,2] [,3] [,4] [,5] [,6] ## [1,] -0.1294118 -0.1333333 -0.1333333 -0.1372549 -0.1372549 -0.1333333 ## [2,] -0.1254902 -0.1254902 -0.1294118 -0.1333333 -0.1333333 -0.1333333 ## [3,] -0.1176471 -0.1215686 -0.1254902 -0.1294118 -0.1294118 -0.1294118 ## [4,] -0.1215686 -0.1215686 -0.1254902 -0.1294118 -0.1294118 -0.1294118 ## [5,] -0.1294118 -0.1294118 -0.1294118 -0.1294118 -0.1294118 -0.1294118
  • 7. Inference Here I reduced the brightness 0.4 now we can see the difference of the image in print state ment. display(b2) hist(b2)
  • 8. #manipulating contrast c1=image4*0.3 Inference Here I increase the image contrast0.3 display(c1)
  • 9. c2=image4*1 Inference last image contrast is very low so again I increase the contrast from 0.3 to 1 .using * symbol we can modify the image contrast display(c2)
  • 12. Inference Gamma is used for manipulate the darkness of the picture. Here, I just increase the darknes s from 0.3 to 0.6 using >and < symbols #color colorMode(image4)=Grayscale print(image4) ## Image ## colorMode : Grayscale ## storage.mode : double ## dim : 1920 1080 3 ## frames.total : 3 ## frames.render: 3 ## ## imageData(object)[1:5,1:6,1] ## [,1] [,2] [,3] [,4] [,5] [,6] ## [1,] 0.2705882 0.2666667 0.2666667 0.2627451 0.2627451 0.2666667 ## [2,] 0.2745098 0.2745098 0.2705882 0.2666667 0.2666667 0.2666667 ## [3,] 0.2823529 0.2784314 0.2745098 0.2705882 0.2705882 0.2705882 ## [4,] 0.2784314 0.2784314 0.2745098 0.2705882 0.2705882 0.2705882 ## [5,] 0.2705882 0.2705882 0.2705882 0.2705882 0.2705882 0.2705882
  • 13. #to return to color colorMode(image4)=Color Inference ColorMode is use for manipulate color. Here I changed the colorMode from color to graysca le and again I changed to color #cropping k=image4[60:860,360:960,] display(k) Inference Cropping is again important manipulating operating in image processing . Here,I just crop in this range of 60:860,360:960. #new image file writeImage(k,"MS.jpg") Inference In EBimage have write operation for save your all updates pictures in your local machine u sing writeImage. #flip,flop,rotate resize
  • 16. o=resize(image4,360) display(o) Inference Using Flip,flop,rotate and resize commands we can flip and flop the image ,rotate the image , and resize the image, which size you want? #low-pass filter low=makeBrush(21,shape = "disc",step = FALSE) low=low/sum(low) image.low=filter2(image4,low) display(image.low)
  • 17. low=makeBrush(81,shape = "disc",step = FALSE) low=low/sum(low) image.low=filter2(image3,low) display(image.low)
  • 19. Inference Low-pass filter and high-pass filter is used for just blur the image whatever you want? # combine c=combine(image3,image4) display(c) ## Only the first frame of the image stack is displayed. ## To display all frames use 'all = TRUE'.
  • 20. Inference We can merge the image one by one using combine command. Here I combine image3 and i mage4 #put two image into one i1=image3+image4 display(i1)
  • 23. Inference Here I put two image into one image If you want second image is more thickness compare with first image just increase the first image thickness using / symbol