[MINC-users] median filter

francois hebert francois.hebert007 at gmail.com
Fri Jan 28 14:44:04 EST 2011


Hello,

I want to filter the data if I use mincstats I will ahve a global effect on
the images no?

Francois

2011/1/28 Vladimir S. FONOV <vladimir.fonov at gmail.com>

> Hello,
>
>
> why not to use mincstat -pctT 50 for this ?
>
>
> Mishkin Derakhshan wrote:
>
>> Alternatively, here is a perl script that does the filtering on the
>> histogram of the data, and not the data itself.
>>
>>
>> #! /usr/bin/perl
>>
>> my $default = 5;
>> if (scalar(@ARGV) < 1) {
>>    usage(1);
>>    exit(1);
>> }
>>
>>
>> my $cnt=0;
>> my ($i, $j, $p);
>> my @pts;
>> my @arr;
>> my @bins;
>> my $median_samples=$ARGV[1];
>>
>>
>> if(!defined($median_samples)){
>>    $median_sample=$default;
>>    print "Using default window size of: $default\n";
>> }
>>
>> open(FIN,"$ARGV[0]");
>> while(<FIN>){
>>    $i="";
>>    chomp;
>>    ($j, $i, $p)=split(/ +/,$_);
>>    #  print "[$j] [$i] [$p]\n";
>>    if($j !~ m/\#/){
>>        if("$i" ne ""){
>>            push @pts, $p;
>>            push @bins, $i;
>>            $cnt++;
>>        }
>>    }
>> }
>>
>> my $hmedian= int($median_samples/2);
>> for ($i=0; $i<=$cnt-$median_samples; $i++){
>>    my @arr;
>>    for ($j=0; $j<=$median_samples; $j++){
>>        $arr[$j]= $pts[$i+$j]
>>    }
>>    my @sorted= sort {$a <=> $b} @arr;
>>    push @filtered, $sorted[$hmedian];
>> }
>>
>> for ($i=0; $i< $hmedian; $i++){
>>    unshift @filtered, $filtered[0];
>>    push @filtered, $filtered[$#filtered];
>> }
>>
>> # print map "$_\n", @filtered;
>> for ($i=0; $i< $cnt; $i++){
>>    print " $bins[$i] $filtered[$i]\n";
>> }
>>
>> sub usage{
>>    @params = @_;
>>    @array = split(/\//,$0);
>>    $me = $array[$#array];
>>    if($params[0]==1){
>>        print "\nDoes a median filter on histogram data. The input
>> file is the output from mincstats\n";
>>        #print "\tOptions:\n";
>>        print "\n[window_size] is the number of bins to include when
>> calculating the median (default: ${default})\n";
>>        print "\n";
>>    }
>>    print "\nUsage:";
>>    print "\t$me <histfile.txt> [window_size]\n";
>>    #print "\t$me -help\n";
>> }
>>
>>
>> On Fri, Jan 28, 2011 at 12:28 PM, francois hebert
>> <francois.hebert007 at gmail.com> wrote:
>>
>>> Thanks a lot.
>>>
>>> Francois
>>>
>>> 2011/1/28 Vladimir S. FONOV <vladimir.fonov at gmail.com>
>>>
>>>  Hello,
>>>>
>>>> looks like mailing list removes attachments. Here it is:
>>>> http://www.bic.mni.mcgill.ca/~vfonov/software/itk_g_morph.cpp<http://www.bic.mni.mcgill.ca/%7Evfonov/software/itk_g_morph.cpp>
>>>> <http://www.bic.mni.mcgill.ca/%7Evfonov/software/itk_g_morph.cpp>
>>>>
>>>>
>>>> francois hebert wrote:
>>>>
>>>>  Hello,
>>>>>
>>>>> Not sure but I think you forgot to attach the file.
>>>>>
>>>>> 2011/1/28 Vladimir FONOV <vladimir.fonov at gmail.com>
>>>>>
>>>>>  Hello,
>>>>>
>>>>>> see attached file for my grayscale morphology program.
>>>>>>
>>>>>>
>>>>>> francois hebert wrote:
>>>>>>
>>>>>>  Thanks for the tip I will have a look on it.
>>>>>>
>>>>>>> Francois
>>>>>>>
>>>>>>> 2011/1/28 Vladimir FONOV <vladimir.fonov at gmail.com>
>>>>>>>
>>>>>>>  Hello,
>>>>>>>
>>>>>>>  I use morphology filters from ITK, using ezminc to interface it with
>>>>>>>> MINC:
>>>>>>>>
>>>>>>>> http://en.wikibooks.org/wiki/MINC/EZMINC
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> francois hebert wrote:
>>>>>>>>
>>>>>>>>  I wuld like to know if there is a median filter in the minc tool or
>>>>>>>> if
>>>>>>>>
>>>>>>>>  somebody have it?
>>>>>>>>> I know that we can specified kernel with mincmoprh but i'm not sure
>>>>>>>>> I
>>>>>>>>> can
>>>>>>>>> use mincmorph to perform the median filtering.
>>>>>>>>>
>>>>>>>>>  --
>>>>>>>>>
>>>>>>>> Best regards,
>>>>>>  Vladimir S. FONOV ~ v.s.fonov  <at> ilmarin.info
>>>>>>
>>>>>> _______________________________________________
>>>>>> MINC-users at bic.mni.mcgill.ca
>>>>>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>>>>>>
>>>>>>
>>>>>>  _______________________________________________
>>>>>>
>>>>> MINC-users at bic.mni.mcgill.ca
>>>>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>>>>>
>>>>>
>>>> --
>>>> Best regards,
>>>>  Vladimir S. FONOV ~ v.s.fonov  <at> ilmarin.info
>>>> _______________________________________________
>>>> MINC-users at bic.mni.mcgill.ca
>>>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>>>>
>>>>  _______________________________________________
>>> MINC-users at bic.mni.mcgill.ca
>>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>>>
>>>  _______________________________________________
>> MINC-users at bic.mni.mcgill.ca
>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>>
>
>
> --
> Best regards,
>  Vladimir S. FONOV ~ v.s.fonov  <at> ilmarin.info
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>


More information about the MINC-users mailing list