« first day (1457 days earlier)      last day (1387 days later) » 

7:13 AM
How does one embed code here ?
`` is like this ?
 
yeah for one-liners it's with back ticks, for multiple lines 4 spaces in front of each line
 
for (int i = 0;i < aaa.size();i += 5)
{
cout << aaa.at(i) << endl;
}
so i have a vector in which i skip every 5 elements
now i want to do this recursively
the next time the loop runs it should skip every 25th element
currently i do this by doing a mod check and checking for remainder
but that uses a IF statement
 
skip every 5 elements or print every 5th element?
 
skip every 5th element
i eventually need to assign it to another array but that is for later
so the next time the loop runs it should skip every 25th element and then every 125th element
powers of 5
what i mean is this - i have a vector of size n. first time it runs the code above i have shown
the next time it skips every 25th element
across the whole vector
and then it skips every 125th element across the whole vector
 
so like

for (int p = 5;p < aaa.size();p *= 5)
for (int i = 0;i < aaa.size(); ++i )
{
if(i%p == 0) continue;
cout << aaa.at(i) << endl;
}
 
7:21 AM
so you do need to have a if check
 
With an if does seem like the most straight-forward way. You could remove every 5th element beforehand, then you don't have any ifs but that doesn't get you much
 
for (int level = 0;level < 9;level++)

{
for (int i = 0;i < aaa.size();i += 5)
{
cout << aaa.at(i) << endl;
}
}
@PeterT so it need to skip every 5 power n each time that outer loop runs
where n is the running value of level
 
ok I don't get it, you saying "skip every 5", to me that means "1 2 3 4 6 7 8 9 11", but you keep writing it with +=5 which seems like "0 5 10 15"
 
ok the first time it runs you are right it it is 0 5 10 15
then the next it is 0 25 50 75 100
and then 0 125 ...
 
for (int p = 5;p < aaa.size();p *= 5)
for (int i = 0;i < aaa.size(); i+=p )
{
    cout << aaa.at(i) << endl;
}
 
7:30 AM
ok. will the outer loop run 9 times then ?
 
depends on how long aaa is
 
assuming it is long enough will it ?
 
for (int j=0,p = 5;j < 9;p *= 5, j++)
for (int i = 0;i < aaa.size(); i+=p )
{
    cout << aaa.at(i) << endl;
}
 
Excellent . Let me try that out. Can this be later vectorized with OpenMPI ? I am assuming yes ?
for large aaa
 
8:05 AM
@PeterT That works ! Thank you very much ! Now I can ask a question on SO whether that nested for loop can be vectorized with OpenMPI or not.
Thanks again !
 
int main(int argc, char *argv[])
{
    char    abc[27];
    char    *ptr = abc;
    strcpy(abc, "abcdefgxyz");
    /*
     * What are the types and values of expressions:
     *

     * 1. abc    A: a character array
     * 2. *abc   A: pointer to a character array
     * 3. abc[2]   A: a character in a char array
     * 4. &abc[3]  A: the address of 4th character
     * 5. abc+4    A: ??? I have no idea
     * 6. *(abc+5) + 2  A: see above
     */
     cout << &abc << endl;


    return 0;
}
could you someone please check my answers for these questions?
 
how is *abc a pointer?
 
yeah thats a bad mistake... it should be a dereferenced char array
 
abc+4 is just character-array implicitly converted to a pointer and then some pointer math on that pointer
then *(abc+5) is essentially abc[5] , so *(abc+5) + 2 => abc[5] +2
 
8:49 AM
Can anyone explain what is actually going on here?
 
seems like the person asking the question explained it fairly well
 
I am dumb, remember?
but seriously, I really am not able to understand that const thing
please explain
 
struct A{
void doStuff() const{
//"this" inside here is const A*
//so this can be called on a const A or a non-const A
}
void doStuff2() {
//"this" inside here is A*
//so this can only be called on a non-const A
}
}
 
Hmm...
then why does:
B& getB(const size_t idx) const {
    return m_bCollection[idx];
}
give error?
C++ qualifiers dropped in binding reference of type to initializer of type
 
@PeterT so abc+4 is 4th char of the char array? makes sense
 
9:05 AM
@Permian I think that is exactly what the compiler does when finding the index. :) It also explains why indexing begins from 0
 
perfect thought so
thanks gusy
 
9:37 AM
@d4rk4ng31 because it's trying to return a B&, but m_bCollection is const, because "this" is const
 
 
5 hours later…
2:37 PM
Who here knows a bit about computer graphics or image processing?
 
nwp
Bad question. Ask your real question.
 
Yeah, I thought so. I wanted someone with a general knowledge because the then they don't mind the code I'm about to drop. Oh well, here goes.
Is this the right way to fill in colors in a bitmap using image bytes in rgb format?
int n = 1;
            uint step = 0;

            for (int y = 0; y < imageHeight; y++, n += 1)
            {
                for (uint index1 = step, index2 = step + 1, index3 = step +2, x = 0; index3 < imageWidth * n; index1 += 3, index2 += 3, index3 += 3, x++ )
                {
                    Color newColor = Color.FromArgb(Raw[0][index1], Raw[0][index2], Raw[0][index3]);
                    bitmap.SetPixel(x, y, newColor);
                }

                step += imageWidth;
            }
I'm getting something like this:
@nwp And say you don't know the pixel format of image bytes, should you still get a picture with the wrong colors, or should you expect the messed up pixels in the image above?
 
nwp
2:53 PM
It looks random, so I would guess you have an RGB vs RGBA mismatch.
And no, you wouldn't see the original picture with wrong colors, it would be completely messed up.
 
@nwp Thanks a lot! Damn it, I hoped that wouldn't be the case.
You see I have these image bytes with an unknown format. I assumed it was ARGB but may it's not.
 
nwp
Try RGB next.
Also that's a lot of confusing index variables. I don't know why you make it so complicated.
 
@nwp Good shout, this is actually RGB. I realized the image bytes were little endian so I first converted them to big endian like this:
byte[] newData = new byte[ImageBytes.Length];

            for (int position = 0; position < ImageBytes.Length; position += 3)
            {
                byte B = ImageBytes[position];
                byte G = ImageBytes[position + 1];
                byte R = ImageBytes[position + 2];

                byte[] rgb = new byte[] { R, G, B };

                Array.Copy(rgb, 0, newData, position, rgb.Length);
            }
@nwp How would you have named them? I'm open to suggestions.
 
nwp
const pixel_size = 3;
for (int step = 0; step < width * height; step++) {
    bitmap.SetPixel(step % width, step / width, Color.FromArgb(RAW[0][step * pixel_size], RAW[0][step * pixel_size + 1], RAW[0][step * pixel_size + 2]));
}
Maybe naming the variables makes sense, but things like index3 += 3 are unnecessary and error-prone.
Also you're not supposed to use new.
 
@nwp that looks concise. The point of the nested for loop I used was because I am iterating along the pixels of the bitmap, row by row, or column by column.
 
nwp
3:05 PM
It might make sense to use const int r_offset = 0; const int g_offset = ... to easily switch between combinations of R, G, B and A.
 
Does you loop achieve the same result?
 
nwp
It should do the same thing. Minus the forgotten int and that you don't have width and height.
 
@nwp you know you just gave me a great idea. I could make my code easier if I renamed index1 to r_offset, index2 to g_offset, and index3 to b_offset. Thanks.
int n = 1;
            uint start = 0;

            for (int x = 0; x < imageWidth; x++, n += 1)
            {
                for (uint r_offset = start, g_offset = start + 1, b_offset = start +2, y = 0; b_offset < imageHeight * n; r_offset += 3, g_offset += 3, b_offset += 3, y++ )
                {
                    Color newColor = Color.FromArgb(imageBytes[r_offset], imageBytes[g_offset], imageBytes[b_offset]);
                    bitmap.SetPixel(x, y, newColor);
                }

                start += imageHeight;
I simplified the naming.
 
nwp
You still have 4 counting variables when you only need 1.
 
@MyWrathAcademia depends on pixel format etc.
 
3:18 PM
@nwp I see, You mean this:
16 mins ago, by nwp
const pixel_size = 3;
for (int step = 0; step < width * height; step++) {
    bitmap.SetPixel(step % width, step / width, Color.FromArgb(RAW[0][step * pixel_size], RAW[0][step * pixel_size + 1], RAW[0][step * pixel_size + 2]));
}
 
nwp
You should probably put const int x = step % width; and so on into the loop to make it readable, but yes.
 
I like the conciseness of your code. The first two arguments of Bitmap.SetPixel should be x then y but you use the width in both arguments. Is this a mistake?
 
nwp
Unless you are starved for resources and every nanosecond counts and you can't afford to use modulo.
 
@nwp I see. What about the y coordinate?
 
nwp
@MyWrathAcademia That should be how you get the x and y coordinate. The height is given implicitly via step which encodes the length of the image.
 
3:24 PM
@Mgetz I meant when the pixel format is rgb?
 
@MyWrathAcademia that's not exactly a specific thing docs.microsoft.com/en-us/windows/win32/wic/…
 
@nwp I'm not seeing how you get the correct x and y coordinate by doing step % width, and step / width, respectively.
 
also if you're doing a LOT of this... it might be easier to use a GPU accelerated library
 
nwp
@MyWrathAcademia Take a 10x15 image and play it through. step = 0 -> x = 0, y = 0 check. step = 9 -> x = 9, y = 0 check. step = 10 -> x = 0, y = 1 check.
 
@nwp I'm assuming 10x15 is width * height. At step 9, step % width is 9. I see it.
@nwp Does this fill all pixels of a bitmap accurately? Iterating along the pixels of a bitmap like I first did is intuitive for me because I can imagine filling in the pixels in the bitmap column by column, or row by row.
With your method I can't determine whether it is fail-safe.
@Mgetz Like OpenCV, or one of its wrappers. Believe me I tried, but I couldn't get it to work.
I've never had so much trouble installing a piece of software.
 
3:40 PM
@MyWrathAcademia see the microsoft docs I linked.. it's not that simple depending on the pixel format
24bpp has weird strides etc
it's not what you'd think it is when it's loaded in
 
@Mgetz Is 24bpp rgb?
 
@MyWrathAcademia or BGR etc... you have to check
all of those are valid technically
 
@Mgetz Christ how many combinations of red, green and blue do I have to check to determine the correct pixel format the unknown image bytes I have. Is it 27?
 
@MyWrathAcademia if you're doing it manually? maybe? I always just told the image library I wanted it in 32BPP BGRA (because I'm on a little endian machine and this made the most sense to me)
the library would then convert it to that
 
@nwp Please clarify what you mean by this?
@Mgetz Which library is this, if you don't mind me asking?
 
3:46 PM
@MyWrathAcademia I was using Windows Imaging Component because I didn't need cross platform
not sure if WIC is particularly performant... but I didn't care for what I was doing.
 
@Mgetz I'm on Mac so I can't use that
 
@MyWrathAcademia if you don't care about cross platform developer.apple.com/library/archive/documentation/…
 
@Mgetz Thanks. How do you install that?
I don't see any installation instructions.
 
nwp
@MyWrathAcademia I wrote const pixel_size = 3; which is missing an int and I didn't see any width or height in your code but used those anyways, so to use my code you'd have to get it from somewhere.
 
@MyWrathAcademia it comes with a mac, it's part of the macos SDK that comes with XCode
 
3:57 PM
@nwp Thanks. I know width * height. It is the bitmap's width and height. Tell me, the way you are using only one for loop, is the idea to loop through the imageBytes elements (i.e. the byte array elements) or to iterate over the area of the bitmap?
@Mgetz Interesting. I'm using visual studio, may be I'll check it out.
 
@MyWrathAcademia TBF this requires interfacing with either objective-c or swift
 
@Mgetz that's a bit of a roadblock. I think I'll stick with familiar territory.
 
@MyWrathAcademia When on apple... you have to deal with apple
if you want a sane OS there are other options
 
@Mgetz Yes, the walled garden
@Mgetz I came from Linux actually.
 
nwp
@MyWrathAcademia Both. They are the same thing. Going through the imageBytes one by one is the same as going through the image line by line. Maybe imagine the image as a series of numbers starting with pixel 0 in the top left, then incrementing until the line is done, then continuing on the next line like a book.
 
4:02 PM
And I use windows for play.
 
@MyWrathAcademia where last I checked OpenCV was literally apt-get install open-cv
Ironically even on windows MS recommends using the 32bit floating point formats because they are GPU accelerated internally
 
@nwp Are you saying that one byte in the imageBytes is like one line in the bitmap? I would think that n bytes in the imageBytes where n is the width of the bitmap is equal to one line in the bitmap?
@Mgetz Interesting.
@Mgetz you mentioned bgr, can the combination of a pixel also be grb, gbr etc.?
 
@MyWrathAcademia Usually it's BGR or RGB, but technically yes it could be
@MyWrathAcademia it makes more sense when you think about it, it allows for finer manipulation without losing as much data in theory and GPUs and most CPUs handle 128bit vectors insanely well
 
@nwp Please can you expand on this with an example?
 
nwp
I already did.
I don't know what more to tell you.
 
4:15 PM
@nwp I'm guessing you mean like the loop variables here:
1 hour ago, by MyWrathAcademia
int n = 1;
            uint start = 0;

            for (int x = 0; x < imageWidth; x++, n += 1)
            {
                for (uint r_offset = start, g_offset = start + 1, b_offset = start +2, y = 0; b_offset < imageHeight * n; r_offset += 3, g_offset += 3, b_offset += 3, y++ )
                {
                    Color newColor = Color.FromArgb(imageBytes[r_offset], imageBytes[g_offset], imageBytes[b_offset]);
                    bitmap.SetPixel(x, y, newColor);
                }

                start += imageHeight;
@Mgetz If I have tried reading imageBytes as RGB and BGR and I'm still getting a messed up output like the following, does that mean that imageBytes is in a different format?
2 hours ago, by MyWrathAcademia
user image
 
@MyWrathAcademia could be, how are you loading the image?
e.g. what library
 
@Mgetz No library, I'm loading the image from the proprietary file described here. I think this repo loads the image but I can't see which pixel format they use.
That's why the image bytes are unknown.
Specifcally this part: u8[height][width] raw fundus image
 
so yeah it's not RGB at all
it's CV_16UC1
 
@Mgetz What?
 
or one of three things actually
 
4:26 PM
@Mgetz I got the idea it is RGB from this line of code.
@Mgetz Why do you think it's not RGB?
I'm interested in the fundus image bytes, not the tomogram slice image bytes.
 
@MyWrathAcademia yes... but if you read that code carefully that's only if the channels header value is 3
if it's one then it's one byte per pixel unsigned
 
@Mgetz Grayscale?
 
@MyWrathAcademia luminance based on that rendering
not quite the same
 
@Mgetz brightness, I see.
 
regardless it's not RGBA or RGB at all in many cases
 
4:35 PM
In the other repo I linked. That class converts either fundus image bytes to an image or tomogram slice image bytes to an image. Can you tell whether that class also considers the fundus image bytes to be one byte per pixel? unsigned?
 
interestingly it doesn't even look for RGB
 
@Mgetz Thanks, you saved me a lot of time I would have spent thinking it was RGBA or RGB, I was looking in the wrong direction. Face palm.
@Mgetz May be RGB is rarely used for that kind of image.
 
@MyWrathAcademia looks like it's always either CV_16UC1 or ` CV_8UC1`
@MyWrathAcademia it may actually reduce the image data actually
NASA doesn't fly color sensors for that reason for example
they take multiple pictures at different wavelengths and composite them IIRC
 
@Mgetz That's a great find. Remember though from the wiki (scroll down to // type == 0x40000000 - image data) I linked, there are two image types fundus image, and tomogram slice image.
I assumed CV_16UC1 was for the tomogram slice as the tomogram slice is described as uf16[height][width] raw tomogram slice image, and CV_8UC1 is for the fundus image bytes because fundus is described as u8[height][width] raw fundus image?
 
dunno
 
4:46 PM
Why do you think the fundus image can be CV_16UC1 or ` CV_8UC1?
 
probably image sensor and device
as well as quality settings
some of the sensors can produce images in the gibibytes or tens of gibibytes
 
@Mgetz okay. To be honest, I haven't tried using CV_16C1 for the imagebytes.
 
so the good news is it sounds like you could actually use OpenCV or whatever... you just need to write code to properly load the image
 
@Mgetz To implement CV_16UC1, that's 2 bytes per pixel, so would it be implemented by setting each 2 bytes to red and green respectively?
@Mgetz Yes it is. I want to have a contigency though, as last time I tried, I couldn't get it to install
 
@MyWrathAcademia the C1 is single channel
so luminance only likely
it doesn't look like any of these are RGB
 
5:04 PM
@Mgetz Right, I overlooked that detail. So one color value gets 2 bytes?
 
one intensity value gets 2 bytes, there's no color in there probably
it's tomography don't those usually use some magnetic resonance or something like that, I don't think there's color involved.
 
@MyWrathAcademia What PeterT said... it's just luminance it looks like
 
@PeterT Luminance is the same as brightness, correct? Thanks for clarifying. I guess it's easy to set luminance using a library, but I don't know how to set it manually like the way I've been setting color values for a Color.
 
it's basically just sensor values. How you interpret intensity is up to you, with >8 bit resolution people often use colormaps
 
@PeterT Yes, that's the tech that produces those images. However, it's the fundus image I'm interested in.
 
5:10 PM
but the simplest way is just to greyscale it by setting red green and blue to the same value
 
@PeterT Right, but is that equivalent to CV_16UC1?
 
16UC1 just means 16-bit unsigned per value and 1 value per pixel
 
@PeterT Do you mean 16-bit unsigned per color value (e.g. red, green or blue) and 1 color value per pixel?
If so, how can you set 16 bits for red, green, or blue. Isn't each color value limited to a byte (i.e. 0 to 255)?
 
just unsigned value per pixel, it's just the format of that one "image", how the data in that value should be interpreted is not encoded in there
it could well be 3 images, one for red one for green and one for blue, as planes or slices each
but 16UC1 implies that for at least that one image with that width and height there's only one value per pixel
Also, there's many different RGB formats and not all of them have 8 bit per channel
 
@Peter I'm a bit confused. First of all what do you mean by value here?
 
5:17 PM
just a numeric value, any more interpretation is not given by CV_16UC1
 
Color value, pixel value, byte value?
 
nvm about that last one, that's just confusing with the cv definition of scalar
 
@PeterT I just had a look in visual studio. And I think that CV_16UC1 means 16 bits per pixel, correct?
 
@MyWrathAcademia Luminance, e.g. how bright a pixel is compared to a value usually black
but it could be any two colors insofar as you can separate them by 65535 different points
 
@PeterT And the pixels are split into 5 bits each for red, green, and blue. Is this right?
 
5:24 PM
what? where did you get that from?
 
@Mgetz That's a good explanation, thanks.
 
it says 1 channel
 
@MyWrathAcademia no, it's just an interpolation
 
@PeterT Oh okay, scratch that last one. So CV_16UC1 means 16 bits per pixel.
 
you need to decide the foreground and background colors
usually they are white and black respectively
 
5:26 PM
I'm just struggling to understand what gets the 16 bits.
 
it's just one value like a "unsigned short"
 
@PeterT How would you implement this?
 
if you want to represent that as simply as possible as a "normal" RGB image you just "rescale" the unsigned short to an unsigned char and assign that one value to all three of R, G and B
 
@MyWrathAcademia you do an interpolation table between the foreground and background
each value in the 65535 values is a different shade that corresponds to a 16 bit value
most image frameworks support this out of the box btw
you just need to tell it that it's single channel 16bbp
open CV supports this out of the box it looks like
 
@PeterT That's good information, but according to u8[height][width] raw fundus image from that wiki, the fundus image bytes I am trying to convert should be an unsigned 8 bit integer (i.e. a byte), so isn't it already an unsigned char since a char can be represented as an integer in the range 0 to 255?
 
5:33 PM
oh... it's not using UINT16 it's using half
that's fun
 
@MyWrathAcademia didn't see that part of the discussion, either way it doesn't look like contains RGB either or it would be u8[height][width][3]
it seems to be "grey scale" either way
yeah, this doesn't look like "fundus" is rgb bitbucket.org/uocte/uocte/src/…
 
@PeterT briliiant detective work.
Using a variation of the nested for loop I posted above (without offsets for red, green, and blue) I just tested setting red, green, and blue for each pixel to the same byte value which gives a grey scale image, and the result is:
The fundus images I see on kaggle are colored though. And I'm also getting no identifiable shape in the above image.
@PeterT is it possible that the e2e proprietary file I have does not contain a fundus image even though the following code indicates that as long as type == 0x40000 there must be either a fundus image, or a tomogram slice image?
 
5:59 PM
there is some noisy vein like stuff at the bottom. Do you have another program to view the same file to make sure the signal you are looking for is in that file
 
@MyWrathAcademia so it's not uint16_t it's half
 
@PeterT Unfortunately, I don't. I'm writing a parser from scratch for that file since the file is proprietary.
I don't see installation instructions for bitbucket.org/uocte/uocte/wiki/Heidelberg%20File%20Format other wise I might try that, but even then there are no instructions on how to use it.
@Mgetz Yeah, a half float, I created a custom float for this parser since the lowest float is 32 bits.
 
It looks like a nomal cmake project, just build it like any other cmake project
 
@PeterT There is also this one.
 
@MyWrathAcademia if you're using clang clang.llvm.org/docs/…
you can use that to extend to 32bit
 
6:11 PM
@PeterT You know I think I will have to, just to see whether there is indeed an image that I'm not resolving.
Fingers crossed compiling works. I haven't built from source on Mac.
@Mgetz wow I didn't know that existed. Thanks.
 
@MyWrathAcademia it's not portable AFAIK but it can speed things up if you need to
because you can have the compiler deal with the quirky crap
 
I'll go for food now, and let you know how I get on with compiling that abandoned bitbucket project's source code.
@Mgetz @PeterT Thanks guys.
 

« first day (1457 days earlier)      last day (1387 days later) »