i have big problem with explanation code under, meanwhile i made two loops function which does the same thing. I send my code to friend to tell me if it is possible to make is simplier 🙂 So i get something like that.
Array.Copy(
myImageData
.Select(
(b, index) =>
(
index > rooflimit && index < floorlimit && b == 252 &&
(myImageData[index + width] == 0 || (myImageData[index + width] > 168 && myImageData[index + width] < 173)) &&
myImageData[index - width] == 252 &&
myImageData[index - (2 * width)] == 159
) ? (byte)172 : b
).ToArray(),
rooflimit + 1,
myImageData,
rooflimit + 1,
floorlimit - rooflimit - 1
);
My loops was doing something like that (above do the same thing):
- when you get all pixelse, copy them to array of bytes
- find all pixels which have value 255, pixel under has 0 or it is from range 168-173
- pixel above has value 255 and pixel 2 times above has value 159
- if i found that pixel change that value to 172
- * pixel checking starts from the second row
[0][1][2], and finish before last row, to be able check pixels above and under of current pixel *
I get almost about that code above, however i don’t understand that part which starts with:
rooflimit + 1,
myImageData,
rooflimit + 1,
floorlimit - rooflimit - 1);
So i ask you for a help, thanks!
PS. please change topic if it is not good specified.
The last four parameters are the last parameters to
Array.Copy. Your code would be clearer if you split it up:I would also be very tempted to use a separate method instead of a lambda expression here – it’s too complicated to be readable, really.