c_merge.c 782 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*!
  2. \file cluster/c_merge.c
  3. \brief Cluster library - Merge
  4. (C) 2001-2009 by the GRASS Development Team
  5. This program is free software under the GNU General Public License
  6. (>=v2). Read the file COPYING that comes with GRASS for details.
  7. \author Original author CERL
  8. */
  9. #include <grass/cluster.h>
  10. /*!
  11. \brief ?
  12. \param C pointer to Cluster structure
  13. \return 0
  14. */
  15. int I_cluster_merge(struct Cluster *C)
  16. {
  17. int band, p;
  18. int c1, c2;
  19. c1 = C->merge1;
  20. c2 = C->merge2;
  21. for (p = 0; p < C->npoints; p++)
  22. if (C->class[p] == c2)
  23. C->class[p] = c1;
  24. C->count[c1] += C->count[c2];
  25. C->count[c2] = 0;
  26. for (band = 0; band < C->nbands; band++) {
  27. C->sum[band][c1] += C->sum[band][c2];
  28. C->sum[band][c2] = 0;
  29. }
  30. return 0;
  31. }