How I can segment the region of an Image?

Cool displays
Post Reply
User avatar
glez_b
Posts: 87
Joined: Thu May 05, 2011 9:19 pm
Contact:

How I can segment the region of an Image?

Post by glez_b »

Hello, hope you are fine.

I want to make a script that calculates certain characteristics in a satellite image for the day April 3, 2004.
The first thing I want to do:

1. how to select the Region of Mexico from a script?

How to convert lines and elements of an image to coordinates of latitude and longitude?

There is some method or function to select the domain mentioned?

2. There is some method or function to display this data from script (for example: hourly data for the day April 3 2004) on screen of McIDAS-V?

3. I want to display a image with the values ??of brightness, where the range is from 201 to 207 and segment the region corresponding to these values. Is there any way to do this?
4. What is the best way to add the features mentioned at the code below

Code: Select all

def scm(directory):
  import os;
  fs = os.listdir(directory);
 
  # now fs will be a list of all the files in directory

  from edu.wisc.ssec.mcidas import AreaFile;
  for name in fs:
   
      print "Reading in:",name
      af = AreaFile(directory+"/"+name);
      ad = af.getAreaDirectory();
      count = 0;
      data = af.getFloatData();
       
      # now look through the first band y count pixels
      # MCS detected when his temperature infrared (TIR) is < 219 K
     
      for i in xrange(ad.getLines()):
          for j in xrange(ad.getElements()):
              if 552 < i < 900 and 244 < j < 572:
                  if (data[0][i][j]) > 206 and (data[0][i][j]) < 208:
                      print i, j, data[0][i][j];
                     

scm("/home/mcidas/Documents/datos/IR")
 
Boris_MCS
User avatar
Rick
Posts: 404
Joined: Fri Jan 16, 2009 8:20 pm

Re: How I can segment the region of an Image?

Post by Rick »

Hi Boris,

To get the region of just Mexico, you'll need a mask. The following area file does just that:

ftp://ftp.ssec.wisc.edu/pub/incoming/mexico-mask.area

You should be able to change your code to mask out the 'non-mexico' pixels. Attached is an example where I loaded both the mask and a real-time image. I changed the color table so all values greater than 0 are transparent.
Attachments
mexican-mask.gif
User avatar
glez_b
Posts: 87
Joined: Thu May 05, 2011 9:19 pm
Contact:

Re: How I can segment the region of an Image?

Post by glez_b »

Exactly what I want to do. But How I do that? Where and how I will be enabled to change the code?.
Boris_MCS
User avatar
glez_b
Posts: 87
Joined: Thu May 05, 2011 9:19 pm
Contact:

Re: How I can segment the region of an Image?

Post by glez_b »

Exactly what I want to do. But How I do that? Where and how I will be enabled to change the code?.

can you help...please
Boris_MCS
User avatar
Rick
Posts: 404
Joined: Fri Jan 16, 2009 8:20 pm

Re: How I can segment the region of an Image?

Post by Rick »

Hi Boris,

You will have to read in two data sources and you can continue to use your code and just and an if statement. Another alternative is to remove your loop and use the mask function as described in the following thread.
viewtopic.php?f=26&t=959

results = mask(ir_source, "<", 230) * mask(mask_source,"=",255)
Post Reply