X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 15 Feb 2014 10:31 AM by  anon
class_doit on classic roi points
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
15 Feb 2014 10:31 AM
    I want to quickly classify a selection of points within an image using k-means. The problem is that 'class_doit' returns an image consisting of a single point when supplied with an roi consisting of multiple points when the following code is used: ; Create roi ENVI_DELETE_ROIS, /all xpts = lindgen(100) ypts = lindgen(100) envi_define_roi, roi_id, /point, xpts=xpts, ypts=ypts ; Open File target = 'D:\Spot\SPOT 5\site\pan_site' envi_open_file, target, r_fid = fid envi_file_query, fid, dims=dims, ns = ns, nl=nl ; Create Roi roiId=envi_create_roi(ns=ns, nl=nl, color=4, name='root') xpts = indgen(100) ypts = indgen(100) envi_define_roi, roiId, /point, xpts=xpts, ypts=ypts dims = [envi_get_roi_dims_ptr(roiId),0,0,0,0] ; Run k-means on image (returns single point image) envi_doit, 'class_doit', dims = dims, fid = fid, method = 7, num_classes = 2, iterations = 2, $ change_thresh = 0.01, pos = [0], r_fid = splitFid, /in_memory ; Returns stats of all points in ROI envi_stats_doit, fid=fid, dims=dims, pos= [0], comp_flag=0, $ report_flag=0, mean=mean, stdv=stdv, dmin=dmin, dmax=dmax print, dmin, dmax, mean, stdv end Is there a way to quickly apply the k-means algorithm to points of an image programmatically? I've tried using a mask of the entire image but I'm hoping to avoid both the time and memory required to build the mask.

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    18 Feb 2014 12:20 PM
    The only way to classify only the points you want is to build and use a mask in CLASS_DOIT. The classification routine must return an image, so using the ROI pointer in the DIMS will not do anything. That can only be used in specific routines that return information such as statistics and not with routines that return an image.

    Deleted User



    New Member


    Posts:
    New Member


    --
    20 Feb 2014 11:13 AM
    Thank you.
    You are not authorized to post a reply.