X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 21 Feb 2022 10:18 PM by  Dane Nguyen
Skip images with no pixels
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Paul Manley



New Member


Posts:8
New Member


--
18 Feb 2022 06:48 AM
    I diced some images and then want to extract spectra the spectra from the dices. Because of how I diced the images, there are now dices that have no pixel information. Instead of manually removing those, I want the foreach loop to skip the ones with no pixels. When running this code:

    1 foreach file, files do begin
    2 raster1 = e.OpenRaster(file)
    3 ;Define ROI with Threshold
    4 roi = ENVIROI()
    5 roi.AddThreshold, raster1, 182, min_value=0, max_value=1
    6
    7 pixelData = raster1.GetData(ROI=roi)
    8 mean = Total(pixelData,1) / roi.PixelCount(raster1)
    9
    10 fname = SPECTRAoutputdir + path_sep() + file_basename(file, '.dat') + '_Diced_Spectra.txt'
    11
    12 openw,1,fname,width=1
    13 printf,1,mean
    14 close,1
    15
    16 endforeach

    I get this error at Line 7 "pixelData = raster1.GetData(ROI=roi)":

    "The EnviRoi does not contain any pixels for this raster."

    Is there an ELSE statement or some way to skip those with no pixels? If no data then proceed? Something? Trying to avoid manually deleting all the images with no pixels.

    Thanks.

    Dane Nguyen



    New Member


    Posts:1
    New Member


    --
    21 Feb 2022 10:18 PM
    Do you have the correct license to do this?
    You are not authorized to post a reply.