Skip to content

Commit

Permalink
version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans-Joachim Klemmt authored and gaborcsardi committed Apr 18, 2014
1 parent 5af4432 commit 390662d
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 23 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ Package: RTextureMetrics
Type: Package
Title: Functions for calculation of texture metrics for Grey Level
Co-occurrence Matrices
Version: 1.0
Date: 2013-12-30
Version: 1.1
Date: 2014-04-18
Author: Hans-Joachim Klemmt
Maintainer: Hans-Joachim Klemmt <hans-joachim.klemmt@lwf.bayern.de>
Description: This package contains several functions for calculation of texture metrics for Grey Level Co-occurrence matrices
License: GPL (>= 2)
Packaged: 2014-01-01 12:38:41 UTC; hajo
Packaged: 2014-04-18 15:21:52 UTC; hajo
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2014-01-04 08:44:34
Date/Publication: 2014-04-19 18:49:32
8 changes: 5 additions & 3 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
e9e61b99ff806999d5068f7749fcb32b *DESCRIPTION
7e5fc368954cdd7e939b44f77f23c381 *DESCRIPTION
df390c53434517b304ac5db487184641 *NAMESPACE
cb8d45ac42ae2d48ff158dbf09918da9 *R/calcASM.R
e3aede1f08b9b87401dbb798a25aaaa5 *R/calcCON.R
9e4cf10c23b32f51f23ccde0dde18901 *R/calcDIS.R
89cb0b3b7153e8ad1c90013d339aeddc *R/calcENT.R
95b87f72c60af025a618ab1682bafc0b *R/calcHOM.R
3826039e6869fa0c0a6e9acde497b46e *R/findMaxPropability.R
06f7b124ae7cbd5c25a4ffb4dada367f *R/genGLCM.R
08d01dc3483ae294b4c75a451e68a4eb *man/RTextureMetrics-package.Rd
001e98769a4f71ef5154431ea5c56a02 *R/genGLCM.R
a2e4902b21a149180e529c288ab08074 *R/plotGLCM.R
bab85359a6baa3ede79af7a2378ce8d9 *man/RTextureMetrics-package.Rd
e20cc2429a048c4b28bd60e334d7fc9b *man/calcASM.Rd
313b411dda0c17fd550f80b61a44e355 *man/calcCON.Rd
e0558c6f35b0dc4b0b54e181b8e03b3b *man/calcDIS.Rd
398a5b02c12d8c898b742c78706395bc *man/calcENT.Rd
7152bbe487ebbc650d6fbd2e1dc41455 *man/calcHOM.Rd
3f88989101adafbfc942bab2fae182d6 *man/findMaxPropability.Rd
cf5e444d6d7ac483ff53d532b2299ca1 *man/genGLCM.Rd
e29f328df8a7eaa7a46aedc25abf61f7 *man/plotGLCM.Rd
25 changes: 11 additions & 14 deletions R/genGLCM.R
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
genGLCM <-
function(direction, distance, rawmat)
{
#distance: 1=east(right) 2=south(down) 3=west(left) 4=north(up)
number_coloums<-max(rawmat)+1
number_rows <-max(rawmat)+1

#generate new GLCM-Matrix after calculation of size of GLCM
#GLCM<-matrix(0, ncol=number_coloums, nrow=number_rows)
#direction: 1=east(right) 2=south(down) 3=west(left) 4=north(up)

#generate new GLCM-Matrix after calculation of size of GLCM
GLCM<-matrix(0, ncol=255, nrow=255)
(GLCM)

#count occurrences and fill the matrix
if(direction==1) ### east-calculation
{
for(i in 1:number_coloums-1) #for all coloumns
for(i in 1:dim(rawmat)[2]-distance) #for all coloumns: -distance because of direction east
{
for(a in 1:number_rows) #for all rows
for(a in 1:dim(rawmat)[1]) #for all rows
{
GLCM[rawmat[a,i]+1,rawmat[a,i+1]+1]<-GLCM[rawmat[a,i]+1,rawmat[a,i+1]+1]+1
GLCM[rawmat[a,i],rawmat[a,i+distance]]<-GLCM[rawmat[a,i],rawmat[a,i+distance]]+1
}
}#eo for
}#eo east calculation

if(direction==2) ### south-calculation
{
for(i in 1:number_coloums) #for all coloumns
for(i in 1:dim(rawmat)[1]-distance) #for all row: -distance because of direction south
{
for(a in 1:number_rows-1) #for all rows
for(a in 1:dim(rawmat)[2]) #for all coloumns
{
GLCM[rawmat[a,i]+1,rawmat[a+1,i]+1]<-GLCM[rawmat[a,i]+1,rawmat[a+1,i]+1]+1
GLCM[rawmat[a,i+distance],rawmat[a,i]]<-GLCM[rawmat[a,i+distance],rawmat[a,i]]+1
}
}#eo for
}#eo east calculation
}#eo south calculation

#add the matrix to its transponse to make it symmetrical
transGLCM<-t(GLCM)
print("INVERTIERT")
print("GLCM generation succesful")
GLCM<-GLCM+transGLCM

#normalize the matrix to turn it into probabilities
Expand Down
17 changes: 17 additions & 0 deletions R/plotGLCM.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
### Function for plotting GLCM-matrices

plotGLCM<-function(GLCM)
{
plot(0,0, xlim=c(0,255), ylim=c(0,255), type="n", main=paste("GLCM-Matrix"))
for(x in 1:255)
{
for(y in 1:255)
{
if(GLCM[x,y]>0)
{
points(x,y, cex=0.25, pch=19)
}
}
}

}##eo function plotGLCM
5 changes: 3 additions & 2 deletions man/RTextureMetrics-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ This package contains several functions for calculation of important texture met
\tabular{ll}{
Package: \tab RTextureMetrics\cr
Type: \tab Package\cr
Version: \tab 1.0\cr
Date: \tab 2013-12-23\cr
Version: \tab 1.1\cr
Date: \tab 2013-04-18\cr
License: \tab GPL (>=2)\cr
LazyLoad: \tab yes\cr
}
Expand Down Expand Up @@ -47,4 +47,5 @@ calcDIS(GLCM)
calcASM(GLCM)
calcENT(GLCM)
findMaxPropability(GLCM)
plotGLCM(GLCM)
}
52 changes: 52 additions & 0 deletions man/plotGLCM.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
\name{plotGLCM}
\alias{plotGLCM}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
plot (plot GLC-Matrix)
}
\description{
\code{plotGLCM} plots a Grey Level Co-occurrence Matrix (GLCM)
}
\usage{
plotGLCM(GLCM)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{GLCM}{
data frame with GLCM data
}

}

\details{
GLCM is a tabulation of how often different combinations of pixel brightness values (grey levels) occur in an image.
}
\value{
no return value
%% If it is a LIST, use
%% \item{comp1 }{Description of 'comp1'}
%% \item{comp2 }{Description of 'comp2'}
%% ...
}
\references{
Toennies, D., 2005: Grundlagen der Bildverarbeitung. Pearson Studium, 341 S.
Harralick, R.M., Shanmugam, K., Dinstein, I., 1973: Textural Features for image classification. IEEE Transactions on Systems, Man and Cybernetics, SMC vol. 3 no. 6, pp. 610-620.
}
\author{
H.-J. Klemmt
}

%% ~Make other sections like Warning with \section{Warning }{....} ~


\examples{
data<-c(0,0,1,1,0,0,1,1,0,2,2,2,2,2,3,3)
mat<-matrix(data,nrow=4, byrow=TRUE)
GLCM<-genGLCM(2,1,mat)
plotGLCM(GLCM)
}

% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ IO }

0 comments on commit 390662d

Please sign in to comment.