X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 26 Jan 2016 02:09 PM by  anon
Build Mask Based on One Bands' DN
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
26 Jan 2016 02:09 PM
    Hi, I would like to build a binary image from a range of DNs of a single band. I'm trying to isolate shadows (if it matters), I need to do a small manipulation to the mask before it is applied to the image, so I need to write the 'raw' mask to disk. I'm using the third band or Value band of the HSV image. This is my code so far, I will adapt it to batch File_Search, but for now I'm just feeding it a hard path to a test image. ; Open the HSV file file = "E:\2013img\LauraZones\processing\LZ01_1vegHSV" raster = e.OpenRaster(file) ;begin HSV manipulation block ValName = file + 'v' ;subset/threshold by DN range 0.1 to 400 in band 3 or V outMASK = file + 'drk400' ;subset HSV to only Value band Val = ENVISubsetRaster(Raster, BANDS=2) iVal = ENVIRaster(Val, URI=ValName) iVal.Save ; generate a mask MAXmask = IMAGE_THRESHOLD(Val, HISTMAX=400, /MASK_INVERT) MINmask = IMAGE_THRESHOLD(MAXmask, HISTMIN=0.1) mVal = ENVIRaster(MINmask, URI=outMASK) mVal.Save Right now the code hangs up on the line iVal = ENVIRaster(Val, URI=ValName). Seams like I don't have a firm understanding of how to pass Virtual Rasters as variables. That might be the problem :/ The last two lines of code are to give the result of the thresholding a logical name on disk, has a high likelihood of being a misstep too, but haven't gotten the code to run that far yet. Any help would be wonderful, Thank you, Laura

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    26 Jan 2016 02:58 PM
    I think the issue is that with virtual rasters, you need to use the Export option to export the results of the subset. There is a pretty good discussion of how to handle subsets and saving of rasters in the following location of the ENVI 5.3 help: Programming > Programming Guide > Working with Rasters or our documentation center: http://www.exelisvis.com/docs/program... For example, Val = ENVISubsetRaster(Raster, BANDS=2) Val.export, valname, 'envi' You might also consider using ENVI's masking routines rather than image threshold here. Masking is also discussed in that same section of the ENVI Programming Guide.

    Deleted User



    New Member


    Posts:
    New Member


    --
    27 Jan 2016 09:07 AM
    That was super helpful. I ended up reversing my logic and making the mask for areas that were above 400, my data has a nodata value of 0 that was being captured in the mask. It would be great if the Thresholding routines had nodata=value keywords. My fixed code ;subset/threshold by >400 in band 3 or V, isolate bright spots outMASK = file + 'brt400' if file_test(outMASK) eq 1 then begin file_delete, outMASK endif ;subset HSV to only Value band, val is virtual raster Val = ENVISubsetRaster(raster, BANDS=2) ; generate a mask threshold = [400.0] mask = ENVIBinaryGTThresholdRaster(Val, threshold) mask.export, outMASK, 'envi'
    You are not authorized to post a reply.