function possamples=getpossamples(VOCopts,class,subset,qnum,nx,ny)
  
subsetfname=sprintf(VOCopts.clsimgsetpath,class,subset);
[ids,gt]=textread(subsetfname,'%s%d');
fprintf('read %d sample names from %s\n',length(ids),subsetfname)

% select images with objects of a given class
indpos=find(gt==1);
clear possamples
possamplesnum=0;
for i=1:length(indpos)
  ind=indpos(i);
  id=ids{ind};
  % read image annotation records 
  xmlfname=sprintf(VOCopts.annopath,id);
  rec=VOCreadrecxml(xmlfname);
  indobj=strmatch(class,{rec.objects(:).class},'exact');
  
  % load image and compute integral gradient image
  img=mean(double(imread(sprintf(VOCopts.imgpath,id))),3);
  ghistintegral=gradimageintegral(img,qnum);
  
  for j=1:length(indobj)
    obj=rec.objects(indobj(j));
    % make sure the object is not occluded / difficult / Frontal or Rear view
    if ~obj.truncated & ~obj.difficult & ~strcmp(obj.view,'Frontal') & ~strcmp(obj.view,'Rear')
      bbox=obj.bbox;
      
      showimage(img); showbbox(bbox);
      title(sprintf('%d(%d) view "%s" | trunc %d | diff %d',i,length(indpos),obj.view,obj.truncated,obj.difficult))
      drawnow
      
      % compute hog descriptor from integral gradient image
      hog=hogintegral(ghistintegral,bbox,nx,ny);
        
      for j=1:size(hog,1)
	possamplesnum=possamplesnum+1;	
	possamples(possamplesnum).id=id;
	possamples(possamplesnum).bbox=bbox(j,:);
	possamples(possamplesnum).dscr=hog(j,:);
      end

    end
  end
end
