Click here to Skip to main content
15,902,765 members

Comments by JONLIN (Top 13 by date)

JONLIN 28-Mar-20 6:53am View    
I'm actually wondering, is it possible to even find a solution that doesn't do it a "brute force" way? Would such a solution find if a subset of the 3D image contain a extrema?
JONLIN 28-Mar-20 6:48am View    
While yes, the code provided wouldn't even compile let alone run. But I'll state it again
"
Given an array with dimensions width=w, height=h and depth=d, find all local maximums and minimums. [...]

A local extrema is found when it is bigger/smaller than all of it's 26 neighbours.
"
3 loops are therefore required for each dimension. The 26 points is the surrounding required to define a extrema, a 3x3x3 box.
This surrounding however is not defined for edges and corners, therefore a extrema can not exist on an edge or corner.
the 3 required loops are therefore
for(int x = 1; x < w-1; x++) {
for(int y = 1; y < h-1; y++) {
for(int z = 1; z < d-1; z++) {
if(isExtrema(x,y,z)) {
//...
}}}}

I am at fault for assuming this, I realize that but I hope this clears up your concerns.
JONLIN 28-Mar-20 6:14am View    
I deemed the full code to be very long but very well I'll update my question.
JONLIN 28-Mar-20 6:13am View    
The definition of a extrema here is that a given pixel is greator or smaller than all of it's 26 neighbours.
It's therefore possible to have 2 adjacent extrema where one is a maximum and the other is a minimum.
There is no weighting attach to extrema (yet, see chapter 4) so all extrema count the same.
JONLIN 17-Jun-16 3:26am View    
I have often found that even if I copy the source straight off there is always some function which doesnt work or something which gives me an error I have no clue how to handle, which was why I was so keen to tell what version of the dll I used etc.
for example this source
http://www.codeproject.com/Articles/686994/Create-Read-Advance-PDF-Report-using-iTextSharp-in
If you want to see the entire source code go to his article Chapter 1 Example 5.

Any code presented is Debopam Pals the link presented above.

PRStream stream;
string content;
PdfDictionary page;
PdfArray contentArray;

// Get the number of pages
int pageCount2 = reader2.NumberOfPages;

// Loop through each page
for (int i = 1; i <= pageCount2; i++)
{
// Get the page
page = reader2.GetPageN(i);

// Get the raw content
contentArray = page.GetAsArray(PdfName.CONTENTS);

if (contentArray != null)
{
// Loop through content
for (int j = 0; j < contentArray.Size; j++)
{
stream = (PRStream)contentArray.GetAsStream(j);

// Convert to a String, NOTE: you might need a different encoding here
content = System.Text.Encoding.ASCII.GetString(PdfReader.GetStreamBytes(stream));

//Look for the OCG token in the stream as well as our watermarked text
if (content.IndexOf("/OC") >= 0 && content.IndexOf(watermarkText) >= 0)
{
//Remove it by giving it zero length and zero data
stream.Put(PdfName.LENGTH, new PdfNumber(0));
stream.SetData(new byte[0]);
}
}
}
}
This for example works great.
In his solution, Even if were to copy it with no alterations it still doesnt work.
more precisly the line
contentArray = page.GetAsArray(PdfName.CONTENTS);
doesnt return anything.
Any ideas?