Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  • please NEVER do anything per pixel ! (can't be said often enough)
  • that opencv has it the rows/cols way is bad enough, but changing the sematics of x or y like x < imageWork.rows makes it only worse. if you ever see yourself writing code like that again -- slap yourself. hard. as often as nessecary.
  • you don't need to copy anthing here, a reshape() will do:


Mat kmeansData = imageWork.reshape(1, imageWork.total()); // 1 channel, 3 cols, H*W rows
  • please NEVER do anything per pixel ! (can't be said often enough)
  • that opencv has it the rows/cols way is bad enough, but changing the sematics of x or y like x < imageWork.rows makes it only worse. if you ever see yourself writing code like that again -- slap yourself. hard. as often as nessecary.worse.
  • you don't need to copy anthing anything here, a reshape() reshape() will do:


Mat kmeansData = imageWork.reshape(1, imageWork.total()); // 1 channel, 3 cols, H*W rows