folder Tahribat.com Forumları
linefolder Programlama Genel
linefolder Matlab Yardım-Fotoğraf Yumuşatma



Matlab Yardım-Fotoğraf Yumuşatma

  1. KısayolKısayol reportŞikayet pmÖzel Mesaj
    omrcyln
    omrcyln's avatar
    Kayıt Tarihi: 14/Nisan/2014
    Erkek

    Matlabda fotoğrafı parametrik olarak yumuşatmayı bilen müritler varsa bir el atsa.Döngüler aracılığıyla yapılacak, filtre kullanılmayacak.Şimdiden teşekkürler

  2. KısayolKısayol reportŞikayet pmÖzel Mesaj
    YeniHarman
    YeniHarman's avatar
    Kayıt Tarihi: 17/Haziran/2012
    Erkek

    Ortalama filtreyi döngü aracılığıyla yapabilirsin. Görüntünün matrisinden 3x3 bölüm al, ortadaki pikseli diğer sekiz pikselin ortalamasına eşitle.


    Olaylara karışmayın!
  3. KısayolKısayol reportŞikayet pmÖzel Mesaj
    stringcompare
    stringcompare's avatar
    Kayıt Tarihi: 05/Ağustos/2006
    Erkek

     C++ fonksiyonu çevirip kullanabilirsin

     

    1. void segImage::imageNoiseRedM(){// Median Average Filter.
    2. int area[9];
    3. for(int i=1;i<height-1;i++){
    4. for(int j=1;j<width-1;j++){
    5. for(int k=-1;k<2;k++){
    6. for(int l=-1;l<2;l++){
    7. area[(k+1)*3+l+1]= data[(i+k)*step+j+l];// All neighbors of current pixel assign to the
    8. }// temporary area array
    9. }
    10. sort(area,area+9);// All neighbors of current pixel sorting.
    11. newData[i*step+j] = area[4];// Median of the area array is assign to the pixel value.
    12. }
    13. }
    14. for(int i=1;i<height-1;i++){// Temp array values assigned to the image data array.
    15. for(int j=1;j<width-1;j++){
    16. data[i*step+j] = newData[i*step+j];
    17. }
    18. }
    19. }
    stringcompare tarafından 31/Ara/14 01:32 tarihinde düzenlenmiştir
  4. KısayolKısayol reportŞikayet pmÖzel Mesaj
    stringcompare
    stringcompare's avatar
    Kayıt Tarihi: 05/Ağustos/2006
    Erkek

    Bonus: bu filtreyi de kullanabilirsin.

     

    1. void segImage::imageBlur(){// Blur operation to blure our image before thresholding.
    2.   int kernel[3][3] ={{1,1,1},// Kernel of Blur.
    3.           {1,1,1},
    4.           {1,1,1}};
    5. int temp;
    6. for(int i=1;i<height-1;i++){// Image Data and Kernel is convoluting.
    7. for(int j=1;j<width-1;j++){
    8. temp=0;
    9. for(int k=-1;k<2;k++){
    10. for(int l=-1;l<2;l++){
    11. temp = temp + (data[(i+k)*step+j+l]*kernel[k+1][l+1])/9;
    12. }
    13. }
    14. if(temp>255)// If temp bigger then 255 or smaller then 0 we have to assign limit values to them.
    15. temp= 255;
    16. if(temp<0)
    17. temp = 0;
    18. newData[i*step+j] = temp;// The new pixel value according to convolution value is putting
    19. }// to the temporary image data array.
    20. }
    21. for(int i=1;i<height-1;i++){// Temp array values assigned to the image data array.
    22. for(int j=1;j<width-1;j++){
    23. data[i*step+j] = newData[i*step+j];
    24. }
    25. }
    26. }
  5. KısayolKısayol reportŞikayet pmÖzel Mesaj
    stringcompare
    stringcompare's avatar
    Kayıt Tarihi: 05/Ağustos/2006
    Erkek

    Bonus 2:

     

    1. void segImage::imageNoiseRedG(int size, float j){// Gaussian Blur Filter.
    2. float kernel[size][size];
    3. for(int k=0; k<size;k++){// Creating Gaussian Kernel According to the formula.
    4. for(int l=0; l<size; l++){
    5. kernel[k][l] =  (1/(2*M_PI*j*j))  * pow( M_E,-1* (k*k + l*l) / 2*j*j );
    6. }
    7. }
    8. int temp;
    9. for(int i=size/2;i<height-size/2;i++){// Image Data and Kernel is convoluting.
    10. for(int j=size/2;j<width-size/2;j++){
    11. temp=0;
    12. for(int k=(int)-size/2;k<(int)size/2+1;k++){
    13. for(int l=-size/2;l<size/2+1;l++){
    14. temp = temp + (data[(i+k)*step+j+l]*kernel[k+(int)(size/2)][l+(int)(size/2)]);
    15. }
    16. }
    17. if(temp>255)// If temp bigger then 255 or smaller then 0 we have to assign limit values to them.
    18. temp= 255;
    19. if(temp<0)
    20. temp = 0;
    21. newData[i*step+j] = temp;// The new pixel value according to convolution value is putting
    22. }// to the temporary image data array.
    23. }
    24. for(int i=size/2;i<height-size/2;i++){// Temp array values assigned to the image data array.
    25. for(int j=size/2;j<width-size/2;j++){
    26. data[i*step+j] = newData[i*step+j];
    27. }
    28. }
    29. }
  6. KısayolKısayol reportŞikayet pmÖzel Mesaj
    omrcyln
    omrcyln's avatar
    Kayıt Tarihi: 14/Nisan/2014
    Erkek
    muhammedonur bunu yazdı

    Bonus: bu filtreyi de kullanabilirsin.

     

    1. void segImage::imageBlur(){// Blur operation to blure our image before thresholding.
    2.   int kernel[3][3] ={{1,1,1},// Kernel of Blur.
    3.           {1,1,1},
    4.           {1,1,1}};
    5. int temp;
    6. for(int i=1;i<height-1;i++){// Image Data and Kernel is convoluting.
    7. for(int j=1;j<width-1;j++){
    8. temp=0;
    9. for(int k=-1;k<2;k++){
    10. for(int l=-1;l<2;l++){
    11. temp = temp + (data[(i+k)*step+j+l]*kernel[k+1][l+1])/9;
    12. }
    13. }
    14. if(temp>255)// If temp bigger then 255 or smaller then 0 we have to assign limit values to them.
    15. temp= 255;
    16. if(temp<0)
    17. temp = 0;
    18. newData[i*step+j] = temp;// The new pixel value according to convolution value is putting
    19. }// to the temporary image data array.
    20. }
    21. for(int i=1;i<height-1;i++){// Temp array values assigned to the image data array.
    22. for(int j=1;j<width-1;j++){
    23. data[i*step+j] = newData[i*step+j];
    24. }
    25. }
    26. }

    Eyvallah hocam.

    1. temp = temp + (data[(i+k)*step+j+l]*kernel[k+1][l+1])/9; 
    2. step i anlayamadım aydınlatabilirmisin :D
  7. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Sherlock.
    r10aldinho
    r10aldinho's avatar
    Kayıt Tarihi: 24/Eylül/2008
    Erkek

    Average Filtresi

    Resimdeki her piksel yerine komşuları ile beraber ortalaması alınarak yeniden hesaplanır. Resimdeki gri düzeyler arasında keskin geçişler azalır; daha yumuşak geçişler söz konusudur. Resim üzerindeki kenarlarda bulanıklaşmaya (blur) yol açarlar.

     

    Seçilen resime yumuşatma filtrelerinden 3x3 ve 5x5 basit ortalama (averaging) filtresi uygulayarak resimlerin görüntülenmesi uygulaması..

     

    a=imread('kitap.jpg');

    b=rgb2gray(a);

    b=im2double(b);

    [w,h]=size(b);

    for i=2:(w-1)

    for j=2:(h-1)

    fa=i-1;fb=i+1;fc=j-1;fd=j+1;

    fk=b(fa,fc)+b(fa,j)+b(fa,fd)+b(i,fc)+b(i,j)+b(i,fd)+b(fa,fd)+b(fb,fc)+b(fb,j)+b(fb,fd);fm=fk*1/9;

    cikis(i,j)=fm;

    if i>2 & j>2 & i<(w-1) & j<(h-1)

    fe=i-2;ff=i+2;fg=j-2;fh=j+2;

    fk=b(fe,fg)+b(fa,fg)+b(fa,fh)+b(fb,fg)+b(fb,fh)+b(i,fg)+b(i,fh)+b(fe,fc)+b(fe,j)+b(fe,fd)+b(fe,fh)+b(ff,fg)+b(ff,fc)+b(ff,j)+b(ff,fd)+b(ff,fh)+b(fa,fc)+b(fa,j)+b(fa,fd)+b(i,fc)+b(i,j)+b(i,fd)+b(fa,fd)+b(fb,fc)+b(fb,j)+b(fb,fd);

    fm=fk*1/25;

    cikisa(i,j)=fm;

    end

    end

    end

    subplot(1,3,1),subimage(b);

    subplot(1,3,2),subimage(cikis);

    subplot(1,3,3),subimage(cikisa);

     

     


    İlk batışını ben gördüm güneşin, Gün dönümüne sen yetiştin, Kaptanı benim bu geminin, En son ben çıkarım, Panik etmeyin ___________________________________________________________ iletisim: www.tahribat.com@gmail.com
  8. KısayolKısayol reportŞikayet pmÖzel Mesaj
    stringcompare
    stringcompare's avatar
    Kayıt Tarihi: 05/Ağustos/2006
    Erkek
    omrcyln bunu yazdı
    muhammedonur bunu yazdı

    Bonus: bu filtreyi de kullanabilirsin.

     

    1. void segImage::imageBlur(){// Blur operation to blure our image before thresholding.
    2.   int kernel[3][3] ={{1,1,1},// Kernel of Blur.
    3.           {1,1,1},
    4.           {1,1,1}};
    5. int temp;
    6. for(int i=1;i<height-1;i++){// Image Data and Kernel is convoluting.
    7. for(int j=1;j<width-1;j++){
    8. temp=0;
    9. for(int k=-1;k<2;k++){
    10. for(int l=-1;l<2;l++){
    11. temp = temp + (data[(i+k)*step+j+l]*kernel[k+1][l+1])/9;
    12. }
    13. }
    14. if(temp>255)// If temp bigger then 255 or smaller then 0 we have to assign limit values to them.
    15. temp= 255;
    16. if(temp<0)
    17. temp = 0;
    18. newData[i*step+j] = temp;// The new pixel value according to convolution value is putting
    19. }// to the temporary image data array.
    20. }
    21. for(int i=1;i<height-1;i++){// Temp array values assigned to the image data array.
    22. for(int j=1;j<width-1;j++){
    23. data[i*step+j] = newData[i*step+j];
    24. }
    25. }
    26. }

    Eyvallah hocam.

    1. temp = temp + (data[(i+k)*step+j+l]*kernel[k+1][l+1])/9; 
    2. step i anlayamadım aydınlatabilirmisin :D

    bu kodu opencv için yazmıştım. opencv de de bir resmin datasına dizi gibi erişemiyorsun.

    elinde 3x5 lik bir dizi olsun. dizinin 2.satır 3.sütun elemanına erişmek istiyorsan: A[1][2] 2 boyutlu bir dizi için istediğin sonucu verir ancak tek boyutlu diziyi iki boyutlu gibi kullanmak istiyorsan A[1*genislik+2] yani step genişlik oluyor fakat opencv de genişlikle de aynı şey anlamına gelmiyor orası biraz opencv nin iç yapısıyla ilgili. step i kullanacaksın yani. matlab de de opencv var ancak onu mu kullanıyorsun bilmiyorum. son olarak bu yazdığım class ın constructor ını paylaşmamışım onu da atarsam daha rahat anlarsın herhalde.

     

    segImage::segImage(IplImage *image) {// Constructor of segImage all necessary variables and methods are there.

    img = image;// Getting image.

    height =img->height;// height, width, step and data is assign to the related varaibles

    width = img->width;

    step = img->widthStep;

    data = (uchar *)img->imageData;

    newData = new uchar[width*height];// newdata will be used to store temp image data.

    label = new int[width*height];// label array store the label of every pixels.

    labelCount=1;// label count store how many label we have.

    for(int i=0;i<width*height;i++)// the first value of every pixel label must be zero.

    label[i]=0;// we will assign a label according to pixels positions.

    }

     

     

  9. KısayolKısayol reportŞikayet pmÖzel Mesaj
    CnkGn
    CnkGn's avatar
    Kayıt Tarihi: 09/Ocak/2011
    Erkek

    oo matlab yapmışım :D


    yo yo yo 1-4-8-3 to the 3 to the 6 to the 9 representing the abq. what up biaatch! leave at the tone...
  10. KısayolKısayol reportŞikayet pmÖzel Mesaj
    omrcyln
    omrcyln's avatar
    Kayıt Tarihi: 14/Nisan/2014
    Erkek

    @muhammedonur  ,  @r10aldinho çok teşekkür ediyorum yardımlarınızdan dolayı yaptım.Eyvallah

    @CnkGn zamanı gelmişti :D 

Toplam Hit: 1166 Toplam Mesaj: 10