Look at task 7 of imgops.c ( only task 7 , the rest is correct…

Look at task 7 of imgops.c ( only task 7 , the rest is correct…

Look at task 7 of imgops.c ( only task 7 , the rest is correct…

Look at task 7 of imgops.c (only task 7

, the rest is correct already)
Before I had this code in task 7

void normalize(uint8_t array[], unsigned int cols, unsigned int rows) {
    uint8_t minValue = min(array, cols, rows);
    uint8_t maxValue = max(array, cols, rows);

    uint8_t MIN_RANGE = 0;
    uint8_t MAX_RANGE = 255;

    uint8_t new_range = MAX_RANGE - MIN_RANGE;
    uint8_t old_range = maxValue - minValue;
    int range = 0;
    double scale = 0;
    for (range = 0; range < rows * cols; range++) {
        scale = (array[range] - minValue) / (old_range);
        array[range] = scale * new_range + MIN_RANGE;
    }

}

And it was always giving 0. I asked the question here: http://stackoverflow.com/questions/38819343/failure-to-normalize-the-dynamic-range-of-an-image
Now my code is like this:void normalize(uint8_t array[], unsigned int cols, unsigned int rows) {
uint8_t minValue = min(array, cols, rows);uint8_t maxValue = max(array, cols, rows);
uint8_t MIN_RANGE = 0;
uint8_t MAX_RANGE = 255;
double new_range = MAX_RANGE – MIN_RANGE +1;double old_range = maxValue – minValue;
int range = 0;double scale = 0;
for (range = 0; range scale = ((array[range] – minValue) / (old_range));array[range] = scale * new_range + MIN_RANGE;
}}
But now it sometimes gives 0 when it should be 255, 147 when it should be 146, 248 when it should be 247, 175 when it should be 174… I don’t know what the problem is. I don’t know if taking the +1 from new_range would solve.
Thank you

Do you need a similar assignment written for you from scratch? We have qualified writers to help you. You can rest assured of an A+ quality paper that is plagiarism free. Order now for a FREE first Assignment! Use Discount Code "FREE" for a 100% Discount!

NB: We do not resell papers. Upon ordering, we write an original paper exclusively for you.

Order New Solution