[vtkusers] K-means values

David Thompson dcthomp at sandia.gov
Fri Mar 18 21:03:47 EDT 2011


> However, I'm still having some trouble accessing the first block of  
> the k-means output, when I use:
> 	vtkTable* tab = vtkTable::SafeDownCast( kMeansStatistics- 
> >GetOutputDataObject( 1 ).GetBlock( 0 ) );
> or just
> 	kMeansStatistics->GetOutputDataObject( 1 ).GetBlock( 0 )
> I'm getting the following error:
>
> error: request for member ‘GetBlock’ in ‘kMeansStatistics.  
> vtkSmartPointer<T>::operator-> [with T = vtkKMeansStatistics]()- 
> > 
> vtkKMeansStatistics 
> ::< 
> anonymous 
> > 
> .vtkStatisticsAlgorithm 
> ::< 
> anonymous 
> > 
> .vtkTableAlgorithm 
> ::<anonymous>.vtkAlgorithm::GetOutputDataObject(1)’, which is of non- 
> class type ‘vtkDataObject*’
>
> Does anyone know what might cause this?

Sorry, that should be
   GetOutputDataObject( 1 )->GetBlock( 0 )
not
   GetOutputDataObject( 1 ).GetBlock( 0 )
(Note the arrow instead of the dot.)

	David

> On Mar 16, 2011, at 5:32 PM, David Doria wrote:
>
>> On Wed, Mar 16, 2011 at 4:07 PM, Sara Rolfe  
>> <smrolfe at u.washington.edu> wrote:
>>>
>>> Hi David,
>>>
>>> It's not a difficult fix, I mainly found it awkward since I  
>>> thought I was missing something simple.  I understand how it works  
>>> better now and can certainly implement it this way.  I appreciate  
>>> your clarification.
>>>
>>> Sara
>>
>> If you recall, I had the same sort of "it feels awkward" issues a
>> while back. I think the problem is that the suite is very very  
>> capable
>> and able to hand very large and serious problems, but many users just
>> want the "very basic" functionality ("which points belong to which
>> cluster?", and "what are the cluster means?"), which is hard to get
>> at. There are many layers of complexity above that that a user must
>> understand (i.e. this "Learn" and "Derive" that you mentioned) that
>> are not concepts in a standard textbook explanation of kmeans
>> clustering. Providing a "simple" interface to do this "one pass" type
>> of thing would definitely be a nice addition.
>>
>> That is, replace:
>>
>>  kMeansStatistics->SetLearnOption( 1 ); // This is on by default.
>>  kMeansStatistics->SetMaxNumIterations( 1 );
>>  vtkTable* tab = vtkTable::SafeDownCast(
>> kMeansStatistics->GetOutputDataObject( 1 ).GetBlock( 0 ) );
>>  double xc = tab->GetValueByName( label, "x" ).ToDouble();
>>
>> with
>>
>> double mean0[3];
>> kMeans->GetMean(0,mean0);
>>
>> See the difference :) ?
>>
>> David D.
>





More information about the vtkusers mailing list