[R] Asking Favor For the Script of Median Filter
Hello,everybody. My name is Chuan Zun Liang. I come from Malaysia. I am just a beginner for R. Kindly to ask favor about median filter. The problem I facing as below: > x<-matrix(sample(1:30,25),5,5) > x [,1] [,2] [,3] [,4] [,5] [1,]78 30 29 13 [2,]46 1259 [3,] 253 22 14 24 [4,]2 15 26 23 19 [5,] 28 18 10 11 20 This is example original matrices of an image. I want apply with median filter with window size 3X# to remove salt and pepper noise in my matric. Here are the script I attend to writing.The script and output shown as below: > MedFilter<-function(mat,sz) + {out<-matrix(0,nrow(mat),ncol(mat)) + for(p in 1:(nrow(mat)-(sz-1))) + {for(q in 1:(ncol(mat)-(sz-1))) + {outrow<-median(as.vector(mat[p:(p+(sz-1)),q:(q+(sz-1))])) + out[(p+p+(sz-1))/2,(q+q+(sz-1))/2]<-outrow}} + out} > MedFilter(x,3) [,1] [,2] [,3] [,4] [,5] [1,]00000 [2,]08 12 140 [3,]0 12 14 190 [4,]0 18 15 200 [5,]00000 Example to getting value 8 and 12 as below: 7 8 30 8 30 29 4 6 12 (median=8) 6 12 5 (median=12) 25 3 22 3 22 14 Even the script can give output. However, it is too slow. My image size is 364*364. It is time consumption. Is it get other ways to improving it? Best Wishes Chuan -- View this message in context: http://r.789695.n4.nabble.com/Asking-Favor-For-the-Script-of-Median-Filter-tp3409462p3409462.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Importing many files from a single code
Dear Ram Kumar Basent: I suggest you restore you file is list. I give my example that I read 50 image by 50 folder. imgA<-list() <-create an empty list for(i in 1:50) <-how many file you need to looping. { imgA[[i]]<-read.jpeg(paste("c:/DataCentre/DataPisA/A",i,"FP3.jpg",sep=""))) } This is my example how I read 50 image in 50 folders. Hope this will hepl you. Best Wishes Chuan -- View this message in context: http://r.789695.n4.nabble.com/Importing-many-files-from-a-single-code-tp838084p3409909.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Asking Favor For "Remove element with Particular Value In Vector"
Dear All. I am Chuan. I am beginner for R.I facing some problem in remove element from vector.I have a vector with size 238 element as follow(a part) [1] 0 18 24 33 44..[238] 255 Let the vector label as "x",I want remove element "0" and "255".I try use such function: x[x>0 & x<255] However, I am fail since same results are give even try it for many times.I also try with shorter vector with 10 element. It is successfully resulted. So,want can I do for it. Kindly asking favor for expert here. Thank you very much. Chuan -- View this message in context: http://r.789695.n4.nabble.com/Asking-Favor-For-Remove-element-with-Particular-Value-In-Vector-tp3772779p3772779.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Asking Favor For "Remove element with Particular Value In Vector"
Thank you friend for suggestion. -- View this message in context: http://r.789695.n4.nabble.com/Asking-Favor-For-Remove-element-with-Particular-Value-In-Vector-tp3772779p3776432.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Asking Favor For "Remove element with Particular Value In Vector"
Thank you very much,friend. -- View this message in context: http://r.789695.n4.nabble.com/Asking-Favor-For-Remove-element-with-Particular-Value-In-Vector-tp3772779p3776427.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Asking Favor For "Remove element with Particular Value In Vector"
Thank you very much,friend. -- View this message in context: http://r.789695.n4.nabble.com/Asking-Favor-For-Remove-element-with-Particular-Value-In-Vector-tp3772779p3776430.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Asking Favor For "Remove element with Particular Value In Vector"
Thank you very much,friend. -- View this message in context: http://r.789695.n4.nabble.com/Asking-Favor-For-Remove-element-with-Particular-Value-In-Vector-tp3772779p3776435.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Asking About packages "rimage"
Dear all: Kindly to ask from R users about the package "rimage" is not available in R version 2.14.1. May I know how I can install this package? Thanks al ot -- View this message in context: http://r.789695.n4.nabble.com/Asking-About-packages-rimage-tp4395719p4395719.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Asking About packages "rimage"
Thanks a lot -- View this message in context: http://r.789695.n4.nabble.com/Asking-About-packages-rimage-tp4395719p4398726.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.