How to increase the contrast in an image, using imagesc, with removal of outliers.
    5 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
Hi,
I have data from a fits file that is displayed with the help of imagesc. The image is very dark (data range in [20 2200]). When I use imcontrast(gca) i can manually remove outliers, and if 0.01% of the outlieres is removed, the data range is [59 1175], and I get the desired contrast.
Is there any way to remove the outliers in the command window, as I have many files to be analysed?
p.s. I know i can use the command imagesc(data, [cmin cmax]),colormap(gray), but the problem is that I dont know cmin and cmax for the different images.
Any help appriciated,
Thank you
Ronni
1 commentaire
  Image Analyst
      
      
 le 30 Juin 2012
				Do you really want to remove outliers from your data, or do you want to keep them but just scale your image for display? Have you tried imadjust()? Or just passing in the display limits into imshow like imshow(yourImage, [42 123])?
Réponses (1)
  Walter Roberson
      
      
 le 30 Juin 2012
        Something like:
ndev = 3;
data_mean = mean(data(:));
data_std = std(data(:));
data_min = min(data(:));
data_max = max(data(:));
cmin = max( data_min, data_mean - ndev * data_std );
cmax = min( data_max, data_mean + ndev * data_std );
imagesc( data, [cmin, cmax] )
3 commentaires
  Image Analyst
      
      
 le 30 Juin 2012
				So go ahead and specify your own limits, using fixed values like I did, or come up with some algorithm like Walter did to derive the value. No one says you need to use his method.
  Walter Roberson
      
      
 le 30 Juin 2012
				cutout = 0.0001;
num_to_cut = ceil( numel(data) * cutout / 2);
sorted_data = sort(data(:));
cmin = sorted_data( num_to_cut );
cmax = sorted_data( end - num_to_cut + 1);
imagesc(data, [cmin, cmax]);
Voir également
Catégories
				En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


