void GrayFilterWidget::applyFilter(InputArray in, OutputArray out) const { // check weather the filter can be applied if (!(checkInput(in).first)) { return; } // the filter can be applied // split the cannels of the input image auto channels = splitChannels(in.at(0).get()); // create a zero image cv::Mat tmp = cv::Mat::zeros(in.at(0).get().rows, in.at(0).get().cols, in.at(0).get().depth()); // multiply all channels with their factor and add it to tmp // if there are factors for more channels than the input image has, this // channels // will be ignored for (std::size_t i = 0; ((i < channels.size()) && (i < chanValues_.size())); i++) { // multiply each channel with its factor and add the result to // tmp tmp += channels.at(i) * (chanValues_.at(i)->value()); } // finally assign tmp to out out.at(0).get() = tmp; }