void findHistogram(IDataArray::Pointer inputData, int32_t* ensembleArray, int32_t* eIds, int NumberOfBins, bool removeBiasedFeatures, bool* biasedFeatures) { DataArray<T>* featureArray = DataArray<T>::SafePointerDownCast(inputData.get()); if (NULL == featureArray) { return; } T* fPtr = featureArray->getPointer(0); size_t numfeatures = featureArray->getNumberOfTuples(); int32_t bin; int32_t ensemble; float min = 1000000.0f; float max = 0.0f; float value; for (size_t i = 1; i < numfeatures; i++) { value = fPtr[i]; if(value > max) { max = value; } if(value < min) { min = value; } } float stepsize = (max - min) / NumberOfBins; for (size_t i = 1; i < numfeatures; i++) { if(removeBiasedFeatures == false || biasedFeatures[i] == false) { ensemble = eIds[i]; bin = (fPtr[i] - min) / stepsize; if(bin >= NumberOfBins) { bin = NumberOfBins - 1; } ensembleArray[(NumberOfBins * ensemble) + bin]++; } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void subtractVector3d(DataArray<double>::Pointer data, double* v) { size_t count = data->getNumberOfTuples(); for (size_t i = 0; i < count; ++i) { double* ptr = data->getPointer(i * 3); ptr[0] = ptr[0] - v[0]; ptr[1] = ptr[1] - v[1]; ptr[2] = ptr[2] - v[2]; } }
void convert(int64_t zStart, int64_t zEnd, int64_t yStart, int64_t yEnd, int64_t xStart, int64_t xEnd) const { int64_t* newindicies = newIndicesPtr->getPointer(0); int64_t index = 0; int64_t ktot = 0, jtot = 0; // float rotMatrixInv[3][3]; float coords[3] = { 0.0f, 0.0f, 0.0f }; float coordsNew[3] = { 0.0f, 0.0f, 0.0f }; int64_t colOld = 0, rowOld = 0, planeOld = 0; for (int64_t k = zStart; k < zEnd; k++) { ktot = (m_params->xpNew * m_params->ypNew) * k; for (int64_t j = yStart; j < yEnd; j++) { jtot = (m_params->xpNew) * j; for (int64_t i = xStart; i < xEnd; i++) { index = ktot + jtot + i; newindicies[index] = -1; coords[2] = (float(k) * m_params->zResNew) + m_params->zMinNew; coords[1] = (float(j) * m_params->yResNew) + m_params->yMinNew; coords[0] = (float(i) * m_params->xResNew) + m_params->xMinNew; coordsNew[0] = rotMatrixInv[0][0] * coords[0] + rotMatrixInv[0][1] * coords[1] + rotMatrixInv[0][2] * coords[2]; coordsNew[1] = rotMatrixInv[1][0] * coords[0] + rotMatrixInv[1][1] * coords[1] + rotMatrixInv[1][2] * coords[2]; coordsNew[2] = rotMatrixInv[2][0] * coords[0] + rotMatrixInv[2][1] * coords[1] + rotMatrixInv[2][2] * coords[2]; colOld = static_cast<int64_t>(nearbyint(coordsNew[0] / m_params->xRes)); rowOld = static_cast<int64_t>(nearbyint(coordsNew[1] / m_params->yRes)); planeOld = static_cast<int64_t>(nearbyint(coordsNew[2] / m_params->zRes)); if(m_SliceBySlice == true) { planeOld = k; } if(colOld >= 0 && colOld < m_params->xp && rowOld >= 0 && rowOld < m_params->yp && planeOld >= 0 && planeOld < m_params->zp) { newindicies[index] = (m_params->xp * m_params->yp * planeOld) + (m_params->xp * rowOld) + colOld; } } } } }